473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XPath: selecting from a sub path


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

Jul 20 '05 #1
4 1627

"Michel Gutierrez" <mi********************@indigen.com> wrote in message
news:pa****************************@indigen.com...

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
Jul 20 '05 #2
In article <pa****************************@indigen.com>,
Michel Gutierrez <mi********************@indigen.com> 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
Jul 20 '05 #3
>> "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

Jul 20 '05 #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

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
1
by: Alastair Cameron | last post by:
VB6, MSXML 3.2 installed: Q1. I am having a problem selecting nodes with XPATH expressions when an attribute values contain backslashes (\\) in as part of its value: For example the...
2
by: Neil Zanella | last post by:
Hello, I would like to know whether the mozilla web browser has built in support for searching XML documents via XPath expressions as with IE's xmlobject's and xmlDoc's function selectNodes() or...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
3
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer>...
4
by: eric.goforth | last post by:
In an xsl stylesheet, I have <xsl:when test="string-length(//mystuff) &gt; 0"> <xsl:attribute name="someattribute">blahblahblah</xsl:attribute> </xsl:when> In the xml that mystuff is several...
2
by: Bilal | last post by:
Hello, I'm stuck on this problem for quite some time and hope somebody would be able to guide me. Basically, I need to populate a large number of "template" XML files which have all...
3
by: Jeff | last post by:
Hi all, I'm wondering if there is a function that will return the xpath to a specific node given its context node. Essentially, I want the reverse of the document.evaluate functionality. I've...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.