XPath expression

kcwolle

Usenet Archive
Joined
Nov 27, 2003
Messages
4
Reaction score
0
Hi,

I'm looking for an XPath expression to get all child elements from an element <ebene> that are not <ebene> elements themselves but have a following or preceing sibling <ebene>.

<buch>
<ebene>
<absatz>Beispieltext</absatz>
<ebene>
<absatz>Ebene 2</absatz>
</ebene>
</ebene>
</buch>

In the above example the only matching node is
<absatz>Beispieltext</absatz>

Any help is appreciated.

Wolfgang
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
kcwolle wrote:

I'm looking for an XPath expression to get all child elements from an element <ebene> that are not <ebene> elements themselves but have a following or preceing sibling <ebene>.

<buch>
<ebene>
<absatz>Beispieltext</absatz>
<ebene>
<absatz>Ebene 2</absatz>
</ebene>
</ebene>
</buch>

In the above example the only matching node is
<absatz>Beispieltext</absatz>

This does what you want:
//ebene/*[local-name != 'ebene' and (preceding-sibling::ebene or following-sibling::ebene)]
 

Bjoern Hoehrmann

Usenet Archive
Joined
Aug 15, 2000
Messages
719
Reaction score
0
* kcwolle wrote in comp.text.xml:
I'm looking for an XPath expression to get all child elements from an element <ebene> that are not <ebene> elements themselves but have a following or preceing sibling <ebene>.

<buch>
<ebene>
<absatz>Beispieltext</absatz>
<ebene>
<absatz>Ebene 2</absatz>
</ebene>
</ebene>
</buch>

In the above example the only matching node is
<absatz>Beispieltext</absatz>

Well, litterally

//ebene/*[not(self::ebene) and
(following-sibling::ebene or preceding-sibling::ebene)]
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top