XPath expression

K

kcwolle

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
 
M

Martin Honnen

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)]
 
B

Bjoern Hoehrmann

* 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
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top