XPath expression

Discussion in 'XML' started by kcwolle, Nov 26, 2004.

  1. kcwolle

    kcwolle Guest

    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
    kcwolle, Nov 26, 2004
    #1
    1. Advertising

  2. 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)]

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 26, 2004
    #2
    1. Advertising

  3. * 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)]
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Bjoern Hoehrmann, Nov 26, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,956
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,369
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    507
  4. goog
    Replies:
    0
    Views:
    496
  5. GIMME
    Replies:
    3
    Views:
    11,923
    vforvikash
    Dec 29, 2008
Loading...

Share This Page