Hi there,
I'm trying to understand how XPath works, I haven't been using it for that long :) I want to be able to select all the siblings of a specified node. For example;
<folder>
<page id="1" />
<page id="2" />
<page id="3" />
<folder id="4">
<page id="5" />
<page id="6" />
</folder>
<folder id="7">
<page id="8" />
</folder>
<page id="9" />
</folder>
Example output...
[@id='5'] //gives 5,6 (all the siblings including 5)
[@id='4'] //gives 1,2,3,4,7,9 (all the siblings including 4)
[@id='8'] //gives just 8 (no siblings exist)
XPath query that I have so far...
/folder//child::*[@id='4']
This singles out the node I'm after, but its siblings (1,2,3...) are not also provided in the nodeset. I'm thinking that from this point I need to select the PARENT of this query, and then its CHILDREN, which will get all the sibling nodes as well. I am not sure how to put this into code, however.
Thanks for any help ;)