There have been a lot of other posts related to this but I can't seem to find the answer to my question. I'm trying to parse an XML file of the following form to return only the items under the 'subGroup' node.
Here is the sample XML:
<?xml version="1.0" ?>
<resultsGroup>
<item>
<id></id>
<title></title>
<description></description>
</item>
<item>
<id></id>
<title></title>
<description></description>
</item>
<subGroup>
<item>
<id></id>
<title></title>
<description></description>
</item>
<item>
<id></id>
<title></title>
<description></description>
</item>
<item>
<id></id>
<title></title>
<description></description>
</item>
</subGroup>
</resultsGroup>
And here is currently what I'm using to parse it:
$.get(url,{},function(data){
$('item',data).each(function(i){
var id = $(this).find("id").text();
var title = $(this).find("title").text();
var description = $(this).find("description").text();
list.append('<li>' + id + ':' + title + ':' + description + '</li>');
});
});
The problem is that the items listed under the 'resultsGroup' are also being selected by $('item',data).each(). I'd appreciate it if someone could explain how to select just those elements under a specific node, in this case the 'subGroup' node.
Thanks in advance for your help!