i have a XML file which is
<?xml version="1.0" encoding="ISO-8859-1"?>
<childrens>
<child id="1" value="Root Catalog" parent_id="0">
<child id="2" value="Apparel" parent_id="1">
<child id="3" value="Accessories" parent_id="2">
<child id="4" value="Handbags" parent_id="3">
<child id="5" value="Jewelry" parent_id="4"/>
<child id="6" value="test1" parent_id="4"/>
<child id="7" value="test2" parent_id="4"/>
<child id="15" value="test3" parent_id="4"/>
</child>
</child>
</child>
<child id="8" value="test_A" parent_id="1">
<child id="9" value="test_B" parent_id="8">
<child id="10" value="test_C" parent_id="9">
<child id="11" value="test_D" parent_id="10"/>
</child>
</child>
</child>
</child>
</childrens>
now i want to find the leaf element of a particular elements
for example i want to find leaf element of Apparel
which is Jewelry, test1, test2, test3 so i want this as my output
i have written this jQuery code to find leaf element
$.ajax({
type: "GET",
url: "test.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('child:empty').filter('child[value="Apparel"]').each(function(){
var id = $(this).attr('id');
alert(id)
});
}
});
if i use only child:empty then it gives me all the leaf element
mine code is not working ...