Reputation: 14877
Consider the following very simplified example.
<n></n>
<k></k>
<m></m>
<k></k>
How can I search for a first k
sibling after m
node? Basically, find some node and then continue searching from that node.
Upvotes: 36
Views: 52087
Reputation: 243449
How can I search for a first
k
sibling afterm
node? Basically, find some node and then continue searching from that node.
Assuming that we have the following well-formed XML document:
<t>
<n></n>
<k></k>
<m></m>
<k></k>
</t>
then the following XPath expression:
/*/m[1]/following-sibling::k[1]
selects the first k
following-sibling of the first m
child of the top element of the XML document.
Upvotes: 62
Reputation: 148524
nice question : try it ........
<a>
<n></n>
<k></k>
<m></m>
<k></k> <====
<k></k>
<m></m>
<k></k>
</a>
/a/k[. = preceding::m][1]
Upvotes: 4