This is the XML file:
<Test> <Category> <SubCat> <Name>Name</Name> <Properties> <Key>Key</Key> <Value>Value</Value> </Properties> </SubCat> <SubCat> <Name>Name</Name> <SubCat> <Name>AnotherName</Name> <Properties> <Key>Key</Key> <Value>Value</Value> </Properties> </SubCat> </SubCat> </Category> </Test>
I want to get a name. But only the name of the first SubCat. And the value of the property key. The problem is that SubCat exists twice.
I tried this:
$(xml).find('SubCat').each(function() { var name = $(this).find("Name").text(); alert(name); }
but it shows the name of the first and second SubCat.
I was looking for something like this.
rootElement(Category).selectallchildren(SubCat).Name for the first SubCat Name rootElement(Category).selectallchildren(SubCat).(SubCat).Name for the second SubCat Name
And the same explicit choice for key and values
source share