XPath: selecting from a sub path

Discussion in 'XML' started by Michel Gutierrez, Apr 13, 2004.

  1. Hi,

    I have an XML document from which the xpath expression
    "A[1]/B[2]/C[3]/D[4]/E[5]/F[6]" selects a node.

    I would expect, in the same document, the expression
    "descendant::C[3]/D[4]/E[5]/F[6]" to select at least the same node. But
    the xpath implementation doesn't return any match.

    I presume I must be wrong somewhere rather than looking for a bug in the
    xpath implementation.

    What am I missing ?

    Thanks,
    /mig
    Michel Gutierrez, Apr 13, 2004
    #1
    1. Advertising

  2. "Michel Gutierrez" <> wrote in message
    news:p...
    >
    > Hi,
    >
    > I have an XML document from which the xpath expression
    > "A[1]/B[2]/C[3]/D[4]/E[5]/F[6]" selects a node.
    >
    > I would expect, in the same document, the expression
    > "descendant::C[3]/D[4]/E[5]/F[6]" to select at least the same node. But
    > the xpath implementation doesn't return any match.
    >
    > I presume I must be wrong somewhere rather than looking for a bug in the
    > xpath implementation.
    >
    > What am I missing ?



    Probably you are evaluating these two XPath expressions against different
    current nodes.


    Cheers,

    Dimitre Novatchev [XML MVP],
    FXSL developer, XML Insider,

    http://fxsl.sourceforge.net/ -- the home of FXSL
    Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
    Dimitre Novatchev [MVP XML], Apr 13, 2004
    #2
    1. Advertising

  3. In article <>,
    Michel Gutierrez <> wrote:

    >I have an XML document from which the xpath expression
    >"A[1]/B[2]/C[3]/D[4]/E[5]/F[6]" selects a node.


    The C matched there is the third C child of the relevant B.

    >I would expect, in the same document, the expression
    >"descendant::C[3]/D[4]/E[5]/F[6]" to select at least the same node. But
    >the xpath implementation doesn't return any match.


    The C matched there is the third C descendant of the current node.

    ..//C[3]/D[4]/E[5]/F[6] will match at least the original node, because
    // means "descendant-or-self::*/".

    -- Richard
    Richard Tobin, Apr 13, 2004
    #3

  4. >>I would expect, in the same document, the expression
    >>"descendant::C[3]/D[4]/E[5]/F[6]" to select at least the same node. But
    >>the xpath implementation doesn't return any match.

    >
    > The C matched there is the third C descendant of the current node.
    >
    > .//C[3]/D[4]/E[5]/F[6] will match at least the original node, because
    > // means "descendant-or-self::*/".


    This solves my problem at 100% !

    Many Thanks !

    /mig
    Michel Gutierrez, Apr 13, 2004
    #4
  5. >> "descendant::C[3]/D[4]/E[5]/F[6]" to select at least the same node. But

    > Probably you are evaluating these two XPath expressions against
    > different current nodes.


    It could have been but the problem was in the expression:
    "descendant::*/C[3]/D[4]/E[5]/F[6]" did it.

    Thanks,
    /mig
    Michel Gutierrez, Apr 13, 2004
    #5
    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. Eych

    sub-selecting a DataTable?

    Eych, Jan 25, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    361
    Jeppe Dige Jespersen
    Jan 26, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,390
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Tristan Miller
    Replies:
    5
    Views:
    984
    Tristan Miller
    Feb 9, 2005
  4. Ben
    Replies:
    2
    Views:
    875
  5. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,015
    Lawrence D'Oliveiro
    May 20, 2011
Loading...

Share This Page