Select next sibling XPath?

Discussion in 'XML' started by Philipp Lenssen, Nov 25, 2003.

  1. I have some chapters a document goes through, so at the end of each
    document I want to output "Continue with XYZ", where XYZ is the
    next-sibling of the current one I select. However I don't know how to
    write the XPath to express this. I tried variants of this with
    ASP/MSXML:

    sPhase = "foo"
    set xNext = xPhasesDoc.documentElement.selectSingleNode(
    "following-sibling::phase[@type = '" & sPhase & "']")

    Where the XML is like

    ----------
    <?xml ...?>
    <content>
    <phase type="foo">Foo</phase>
    <phase type="bar">Bar</phase>
    </content>
    ----------

    How do I do it?
    It's relatively easy to do it another way but I would like to know the
    XPath variant...
     
    Philipp Lenssen, Nov 25, 2003
    #1
    1. Advertising

  2. "Philipp Lenssen" <> wrote in message
    news:bpvhdo$1s3fvd$-berlin.de...
    > I have some chapters a document goes through, so at the end of each
    > document I want to output "Continue with XYZ", where XYZ is the
    > next-sibling of the current one I select. However I don't know how to
    > write the XPath to express this. I tried variants of this with
    > ASP/MSXML:
    >
    > sPhase = "foo"
    > set xNext = xPhasesDoc.documentElement.selectSingleNode(
    > "following-sibling::phase[@type = '" & sPhase & "']")
    >
    > Where the XML is like
    >
    > ----------
    > <?xml ...?>
    > <content>
    > <phase type="foo">Foo</phase>
    > <phase type="bar">Bar</phase>
    > </content>
    > ----------
    >
    > How do I do it?



    Use:

    set xNext =
    currentPhaseNode.selectSingleNode("following-sibling::phase[@type = '"

    & currentPhaseNode.getAttribute("type")

    & "' ][1]")

    where currentPhaseNode is the current "phase" node.


    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL
     
    Dimitre Novatchev, Nov 25, 2003
    #2
    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. Michael K?nig
    Replies:
    2
    Views:
    19,650
    David Carlisle
    Apr 22, 2005
  2. Replies:
    1
    Views:
    2,392
    Bjoern Hoehrmann
    Dec 6, 2005
  3. Replies:
    11
    Views:
    653
    Fredrik Lundh
    Jan 23, 2006
  4. Deniz Bahar
    Replies:
    2
    Views:
    479
    Andrey Tarasevich
    Mar 9, 2005
  5. jman
    Replies:
    2
    Views:
    121
    Martin Honnen
    Dec 12, 2008
Loading...

Share This Page