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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top