Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XPath - returning nodes if all childnodes exist

From: steve.hayter@------.--.--
To: 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



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent