473,405 Members | 2,176 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,405 software developers and data experts.

How to move to a specifc Node

Hi All,

I have a small XML file as below (books.xml)

<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
</bookstore>

I want to find out how I can reach the node <authorwithout navigation
through each node.

I am trying to use the following code in C#. I do not get any error but the
node position is still at the root. How can I reach the node level that I want

XPathDocument doc = new XPathDocument("books.xml");

XPathNavigator nav;
nav = doc.CreateNavigator();
nav.MoveToRoot();
nav.MoveToNamespace("/bookstore/book/authro");

I may be using the correct methods to navigate to the correct root, but I
want to know how I can achieve this.

Thanks
Pradeep_tp
May 11 '07 #1
1 4371
untested:

nav = doc.CreateNavigator()
Dim node As XPathNavigator = nav.SelectSingleNode("bookstore/book/author")

When you called nav.MoveToRoot and then nav.MoveToNameSpace("/bookstore...
I'm not sure what you would get since you have no namespace that I can see
and even if you did nav.SelectSingleNode("/bookstore/... you would get
nothing since you are starting at the "bookstore" node when you MoveToRoot
and there are no child nodes with "bookstore".

i.e.
<bookstore>
<bookstore>
<book>...</book>
</bookstore>
</bookstore>

Rick

"pradeep_TP" <pr*******@discussions.microsoft.comwrote in message
news:6D**********************************@microsof t.com...
Hi All,

I have a small XML file as below (books.xml)

<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
</bookstore>

I want to find out how I can reach the node <authorwithout navigation
through each node.

I am trying to use the following code in C#. I do not get any error but
the
node position is still at the root. How can I reach the node level that I
want

XPathDocument doc = new XPathDocument("books.xml");

XPathNavigator nav;
nav = doc.CreateNavigator();
nav.MoveToRoot();
nav.MoveToNamespace("/bookstore/book/authro");

I may be using the correct methods to navigate to the correct root, but I
want to know how I can achieve this.

Thanks
Pradeep_tp

May 12 '07 #2

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

Similar topics

3
by: \(¯`·.¸FlacK¸.·´¯\) | last post by:
Hi! I want to move a node from file "film1" to "film2" that has tag "FilmatoPartita". I have write the codo below, but it don't do anything...I don't see the error... I have forgotten something?...
2
by: vijay | last post by:
Hi, Can we do something like we select nodes from one tree and when we press a button like "Add" It will move that node with its parent node to the tree to the right? Is this possible in...
1
by: beachboy | last post by:
How I can Move up or down XmlElement? Please advise. Thanks in advanced.
2
by: beachboy | last post by:
How I can Move up or down XmlElement? Please advise. Thanks in advanced.
0
by: K B | last post by:
Hi again, I have a treeview, I would like to select a node, then click on an up or down button and move the node accordingly, updating the xmlDocument each time. For example, if I select a 2nd...
35
by: Frederick Gotham | last post by:
(Before I begin, please don't suggest to me to use "std::vector" rather than actual arrays.) I understand that an object can have resources (e.g. dynamically allocated memory), and so we have to...
1
by: Patrick | last post by:
Hi, I have a xml file like this: <?xml version="1.0"?> <home> <page name="Test1" id="1"> <page name="Pagetest1" id="2" src="test1.htm"></page> <page name="pagetest3" id="3"...
1
by: rampm2007 | last post by:
Hi, I am using the XmlTextReader along XmlValidatingReader for parsing the XML file. Becuase of the foreign characters sometimes I get the "There is an invalid character in the given encoding"...
3
by: John Rogers | last post by:
How do you move a selected node up or down a treeview? Not by drag and drop but by clicking a button to move the node up or down. I tried the following, but my tree gets all messed up after I...
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: 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
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.