I have a xml doxument that looks like this:
<create>
<customers>
<customer>
<first-name>foo</first-name>
<last-name>bar</last-name>
...
</customer>
...
</customers>
</create>
How can I address a single node, which appears several times? I’ve alredy tried this but it isn’t working
var text = xmlDocument.find('customer')[0].text();
// do something
Following code is working but is inappropiate:
xmlDocument.find('customer').each(function() {
var text = $(this).text();
// do something
});
Use
or
or
[0]selects the underlying DOM node, not the jQuery object.