XPath: selecting from a sub path

M

Michel Gutierrez

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
 
D

Dimitre Novatchev [MVP XML]

Michel Gutierrez said:
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
 
R

Richard Tobin

Michel Gutierrez said:
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
 
M

Michel Gutierrez

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
 
M

Michel Gutierrez

"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
 

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

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top