473,387 Members | 1,404 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,387 software developers and data experts.

SelectNodes and xpath.

SelectNodes under 1.1 is confusing me.

Imagine an xml file that looks like this. It's just an example:
<drive>
<dir a="a">
<file>aA</file>
<file>aB</file>
<dir a="ab">
<file>abA</file>
<dir a=abc>
<file>abcA</file>
</dir>
<dir a="b">
<file>bA</file>
</dir>
</drive>

If I selectnodes on //drive/dir I'd get a node list of two items dir's
a=a and a=b. So far so good.
Now I have a recursive method to which I pass each of the nodes in the
nodelist and attemp to selectnodes on the node to return any sub
directory. instead it operates on (I assume) the document property of
the node so we end up running out of stack.

Is there an xpath qualifier or way to selectnodes from a node without
starting at the top short of creating a new document based on the
node's outerxml?
thanks

Jan 19 '07 #1
2 3200
The //drive is what's hosing you; it's an absolute path where you need a
relative one. You can SelectNodes on just //dir, and then any of those
nodes, you can just SelectNodes("dir") (or maybe "./dir"), as the XPath
relative references work very much like command line prompts in both Unix
and Windows.

Jan 19 '07 #2
Gold star in the post :) Many thanks.
Keith Patrick wrote:
The //drive is what's hosing you; it's an absolute path where you need a
relative one. You can SelectNodes on just //dir, and then any of those
nodes, you can just SelectNodes("dir") (or maybe "./dir"), as the XPath
relative references work very much like command line prompts in both Unix
and Windows.
Jan 19 '07 #3

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

Similar topics

7
by: Robert Mark Bram | last post by:
Hi All! In the code below, I am reading in an xhtml document and attempting to use selectNodes to find a <p id="rmb"> node.. But the result is: 2 - */* 0 - */p Can anyone suggest what I...
2
by: suresh | last post by:
Hi, I have the following xml file. <Navigator xmlns="urn:uuid:721DCCFA-8250-4820-8C7D- 7AF0E52305FD"> <SMDataSet RegionName="NA" CustomerName="ATT" MarketName="New Jersey"...
2
by: Echo 8 | last post by:
Is there a simple way of compare dates? I am trying to create a list of perishable stock in an inventory that is near or past its expiration date. I've tried telling it to compare a node's value...
2
by: Michael H | last post by:
Hello group, I have a some xml that looks like this below: <tuneRequests ct="3" xmlns:sql="urn:schemas-microsoft-com:xml-sql" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <tr...
2
by: Linda Boumarafi | last post by:
Hi, This is a newbie question to XMLNS. I just finished the article on "XML Namespaces and How They Affect XPath and XSLT" by Dare Obasanjo and I'm pretty sure I understand the problem. I just...
2
by: Joe | last post by:
Hello All: Does anyone know the differnce between the GetElementsByTagName method and the SelectNodes method? I know that they take different arguments. They also both return a NodeList. I'm...
3
by: Woon Kiat | last post by:
I have this Xml file, bookstore.xml <Bookstore xmlns="http://www.book.com"> <Shelve index="1"> <Book name="Da Vinci Code" /> </Shelve> <Shelve index="2"> <Book name="The Holy Grail" />...
3
by: John Smith | last post by:
I'm trying to make some Javascript X-browser. foo is a HTML DOM. I have foo.documentElement.selectNodes("xpath"); in the source. I see later down there is also a foo.transformNode. Yuck. ...
1
by: Jazper | last post by:
hi i have a problem querying a simple atom-feed by xpath using the XmlDocument. i'm googleing for hours now and can't get a solution: --- Code --- XmlDocument doc = new XmlDocument();...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.