Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: XPath - returning nodes if all childnodes exist XPath - returning nodes if all childnodes existTo: NULL Date: 7/2/2007 1:33:00 AM Hi, Bit of a strange query with XPath here. Essentially I have an XML document with multiple lists, each containing multiple items. Some items can only be available depending on specific values being selected in other lists. So a typical XML chunk may look like this: <list id="4" <item id="1" text="Leeds"> <dependentlist id="1"> <dependentitem id="1" /> </dependentlist> <dependentlist id="2"> <dependentitem id="1" /> </dependentlist> </item> </list> Meaning that this item is only available if item 1 has been selected in list 1, AND item 1 has been selected in list 2. Now I am using XPath to get items for a list, and the selected items. So I am basically looking for all the item nodes where the dependentlist is 1 AND 2, and the relevant item id is selected. Now I have tried: /lists/list[@id='4']/item/dependentlist/dependentitem[@id='1']/ parent::*[@id='1' and @id='2']/parent::* But this obviously doesn't work since the parent node doesn't have @ids of 1 and 2. I have also tried /lists/list[@id='4']/item/dependentlist/dependentitem[@id='1']/ parent::*[@id='1' or @id='2']/parent::* But again, not right since it finds items with dependentlists of 1 OR 2 = whereas I want both. So in plain english, I want to return all the item nodes that contain all nodes for specified dependentlists (in the example above, 1 and 2). So if I searched for dependentlists 1 and 3, nothing would be returned. Is this even possible? Can anyone give me a nudge in the right direction? :) Please go easy on me, I am fairly new to this Xpath stuff! Thanks Steve | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
