Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XPath - returning nodes if all childnodes exist [Thread Next] Re: XPath - returning nodes if all childnodes existTo: NULL Date: 7/3/2007 12:21:00 PM Hi Steve, I have read once over your problem but not tried too hard to understand it fully. As a gut feeling you might be well to try accessing the relevant nodesets with other XPath axes like preceding:: and following:: together with appropriate predicates. Like I say this is only a hunch given 5 seconds thought, though I am sure that XPath is powerful enough to solve your particular problem if you persist. Regards Justin Johansson steve.hayter@v... wrote: > 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 | |||
|
