How to find XML node by attribute, compare it to known string, and if matching, get s
Hello,
I am trying to figure out how to find an XML node by way of one of its attributes, compare that attribute to a known string, and once I find the match, get the sibling attribute in that same node.
Here is what I have so far.
Code:
var glossaryObj = {};
$.get(pURL, function(xmlFile)
{
$.ajax({
type: "GET",
url: pURL,
dataType: "text",
success: parseGlossXML
});
});
function parseGlossXML(xml)
{
glossaryObj = xml
$(glossaryObj).find('term').each(function(){
alert($(glossaryObj).filter(":first").attr('def'));
});
}
This is a sample of the XML file, it is not the complete file.
Code:
<item term="AAA" def="Not the American Automobile Association" rollover="Anti-aircraft Artillery" />
<item term="ABCCC" def="Airborne Battlefield Command and Control Center" />
<item term="ABP" def="Air Battle Plan" />
<item term="AC" def="Active Component" />
Thanks in advacne for any tips or advice.