[xpath] Selecting the position of a node relative to its siblings?

Discussion in 'XML' started by Cory Nelson, Dec 26, 2006.

  1. Cory  Nelson

    Cory Nelson Guest

    I'm trying to get a node position, something like foo/bar[1]/position()
    giving 2 for <foo><bleh><bar></foo>

    Nothing I've tried has worked, so I'll be grateful for any help!
     
    Cory Nelson, Dec 26, 2006
    #1
    1. Advertising

  2. Cory  Nelson

    Peter Flynn Guest

    Cory Nelson wrote:
    > I'm trying to get a node position, something like foo/bar[1]/position()
    > giving 2 for <foo><bleh><bar></foo>


    That's not well-formed. Did you mean

    <foo><bleh/><bar/></foo>

    > Nothing I've tried has worked, so I'll be grateful for any help!
    >


    foo/bar[1]/count(preceding-sibling::*)+1

    ///Peter
    --
    XML FAQ: Http://xml.silmaril.ie/
     
    Peter Flynn, Dec 26, 2006
    #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. Alastair Cameron
    Replies:
    1
    Views:
    7,533
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  2. nobody
    Replies:
    4
    Views:
    1,397
    nobody
    Feb 15, 2004
  3. Dimitre Novatchev
    Replies:
    2
    Views:
    473
    Dimitre Novatchev [MVP XML]
    Feb 15, 2004
  4. Tjerk Wolterink

    XPath: Selecting namspace node

    Tjerk Wolterink, Sep 18, 2004, in forum: XML
    Replies:
    1
    Views:
    447
    Tjerk Wolterink
    Sep 18, 2004
  5. iliad
    Replies:
    4
    Views:
    1,972
    iliad
    Sep 25, 2005
Loading...

Share This Page