xpath expression to return the following node

R

ricky

I want to return with only one xpath expression the first following
node relative to a node with a XPTO attribute.

Example:

<node>
xxx
</node>
<node XPTO="true">
yyy
</node>
<node>
zzz
</node>

i want to return a reference to the node:

<node>
zzz
</node>


thanks in advance
ricky
 
P

Philippe Poulard

ricky said:
I want to return with only one xpath expression the first following
node relative to a node with a XPTO attribute.

Example:

<node>
xxx
</node>
<node XPTO="true">
yyy
</node>
<node>
zzz
</node>

i want to return a reference to the node:

<node>
zzz
</node>


thanks in advance
ricky

hi,

try this :
//node[preceding::node[@XPTO]][1]

what would you expect if there were several nodes with the XPTO attribute ?
--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 
M

Martin Honnen

ricky said:
I want to return with only one xpath expression the first following
node relative to a node with a XPTO attribute.

Example:

<node>
xxx
</node>
<node XPTO="true">
yyy
</node>
<node>
zzz
</node>

i want to return a reference to the node:

<node>
zzz
</node>

This XPath
//node[@XPTO = 'true']/following-sibling::*[1]
finds the first sibling element node.
 
R

ricky

Martin Honnen said:
ricky said:
I want to return with only one xpath expression the first following
node relative to a node with a XPTO attribute.

Example:

<node>
xxx
</node>
<node XPTO="true">
yyy
</node>
<node>
zzz
</node>

i want to return a reference to the node:

<node>
zzz
</node>

This XPath
//node[@XPTO = 'true']/following-sibling::*[1]
finds the first sibling element node.



Thanks a lot.
Works perfectly.
I thought that the use of axis were only permitted in the begining of
xpath expression. Need to read more Xpath specification :)

Ricky
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top