Can XPath return only nodes that have a child of X - with namespaces?

saotinhyeu

New Member
This question is a continuation of Can XPath return only nodes that have a child of X? .I want to find all "pets" that have foo, where some pets have a namespace and other pets do not.Is it possible to use XPath to select only the nodes that have a particular child elements? For example, from this XML I only want the elements in pets that have a child of 'bar'. So the resulting dataset would contain the lizard and pig elements.\[code\]<pets xmlns="urn:cat-org:v1"> <cat> <foo>don't care about this</foo> </cat> <dog xmlns:v1="urn:cat-org:v1"> <v1:foo>not this one either</foo> </dog> <lizard> <bar>lizard should be returned, because it has a child of bar</bar> </lizard> <pig xmlns:v55="urn:cat-org:v1"> <v55:bar>return pig, too</bar> </pig></pets>\[/code\]Any advice would rock.
 
Back
Top