Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XPath: selecting from a sub path

Reply
Thread Tools

XPath: selecting from a sub path

 
 
Michel Gutierrez
Guest
Posts: n/a
 
      04-13-2004

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

 
Reply With Quote
 
 
 
 
Dimitre Novatchev [MVP XML]
Guest
Posts: n/a
 
      04-13-2004

"Michel Gutierrez" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
>
> 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


 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      04-13-2004
In article <(E-Mail Removed)>,
Michel Gutierrez <(E-Mail Removed)> 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
 
Reply With Quote
 
Michel Gutierrez
Guest
Posts: n/a
 
      04-13-2004

>>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

 
Reply With Quote
 
Michel Gutierrez
Guest
Posts: n/a
 
      04-13-2004
>> "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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Death To Sub-Sub-Sub-Directories! Lawrence D'Oliveiro Java 92 05-20-2011 06:50 AM
Recognising Sub-Items and sub-sub items using xslt Ben XML 2 09-19-2007 09:35 AM
Selecting sub-images with wxPython Odalrick Python 0 10-20-2006 10:15 PM
XSLT: selecting a single sub-element to print Tristan Miller XML 5 02-09-2005 01:16 AM
sub-selecting a DataTable? Eych ASP .Net 3 01-26-2005 02:08 PM



Advertisments