I've been using jQuery .find() to do xml traversal, and I'm finding that occasionally I have a child tag in a tree that will collide with a tag somewhere further up the tree. For instance...
<?xml version="1.0" encoding='UTF-8'?>
<userInfo>
<firstname>This is a firstname</firstname>
<lastname>This is a last name</lastname>
<appSpecific>
<location></location>
<nickname>First L</nickname>
<status></status>
<color>FFB141</color>
<lastName>Oops, second name</lastName>
<firstName>Oops, second name</firstName>
<gender></gender>
<timezone></timezone>
<active>true</active>
<languages></languages>
<homepage></homepage>
</appSpecific>
</userInfo>
Now, when I do this:
var firstname = $(xml).find("firstname").text();
var lastname = $(xml).find("lastname").text();
The output is the contents of both sets of tags.
Is there a good way to filter out child tags (especially since I know the parent tag I want to filter)?
I was trying some combo of .filter and .children, but can't seem to get it to work. Any help much appreciated.
Thanks, Josh