473,396 Members | 1,860 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.

Problems selecting node

Hi,

I have the following xml file which is part of a n-level tree:

<TREENODES>
<TreeNode Text="A1" NodeData="1" NavigateUrl="" ImageUrl="">
<TreeNode Text="A2" NodeData="12" NavigateUrl=""
ImageUrl=""></TreeNode>
<TreeNode Text="A3" NodeData="13" NavigateUrl=""
ImageUrl=""></TreeNode>
<TreeNode Text="A22" NodeData="14" NavigateUrl=""
ImageUrl=""></TreeNode>
</TreeNode>
<TreeNode Text="B53" NodeData="2" NavigateUrl="" ImageUrl="">
<TreeNode Text="B29" NodeData="15" NavigateUrl=""
ImageUrl=""></TreeNode>
</TreeNode>
</TREENODES>

and i'm trying to select all descendants of a node with NodeData=x but i
can't seem to select the parent. (black page)
here the code:

Dim doc As XPathDocument = New
XPathDocument(Server.MapPath("Xml/LocationsTree.xml"))

Dim nav As XPathNavigator = doc.CreateNavigator()

nav.MoveToRoot()

nav.MoveToId("descendant::TREENODES[@NodeData='2']")

Response.Write(nav.GetAttribute("Text", ""))
what am i doing worng ?
Nov 12 '05 #1
3 2733
Tamir Kamara wrote:
<TREENODES>
<TreeNode Text="A1" NodeData="1" NavigateUrl="" ImageUrl="">
<TreeNode Text="A2" NodeData="12" NavigateUrl=""
ImageUrl=""></TreeNode>
<TreeNode Text="A3" NodeData="13" NavigateUrl=""
ImageUrl=""></TreeNode>
<TreeNode Text="A22" NodeData="14" NavigateUrl=""
ImageUrl=""></TreeNode>
</TreeNode>
<TreeNode Text="B53" NodeData="2" NavigateUrl="" ImageUrl="">
<TreeNode Text="B29" NodeData="15" NavigateUrl=""
ImageUrl=""></TreeNode>
</TreeNode>
</TREENODES>

and i'm trying to select all descendants of a node with NodeData=x but i
can't seem to select the parent. (black page)
here the code:

Dim doc As XPathDocument = New
XPathDocument(Server.MapPath("Xml/LocationsTree.xml"))

Dim nav As XPathNavigator = doc.CreateNavigator()

nav.MoveToRoot()

nav.MoveToId("descendant::TREENODES[@NodeData='2']")


MoveToId method moves XPathNavigator to a node with specified ID.
"descendant::TREENODES[@NodeData='2']" doesn't look like ID.

Try
XPathNodeIterator ni =
nav.Select("/TREENODES/descendant::TreeNode[@NodeData='2']")
etc.
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #2
Oleg,

still i don't get any output on the page with this code:
Dim ni As XPathNodeIterator

ni = nav.Select("/TREENODES/descendant::TreeNode[@NodeData='2']")

Response.Write(ni.Current.GetAttribute("Text", ""))

it also returns false on the "ni.Current.HasAttributes" line which i don't
get if ni is on the current node.

more ideas ?

thanks
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Tamir Kamara wrote:
<TREENODES>
<TreeNode Text="A1" NodeData="1" NavigateUrl="" ImageUrl="">
<TreeNode Text="A2" NodeData="12" NavigateUrl=""
ImageUrl=""></TreeNode>
<TreeNode Text="A3" NodeData="13" NavigateUrl=""
ImageUrl=""></TreeNode>
<TreeNode Text="A22" NodeData="14" NavigateUrl=""
ImageUrl=""></TreeNode>
</TreeNode>
<TreeNode Text="B53" NodeData="2" NavigateUrl="" ImageUrl="">
<TreeNode Text="B29" NodeData="15" NavigateUrl=""
ImageUrl=""></TreeNode>
</TreeNode>
</TREENODES>

and i'm trying to select all descendants of a node with NodeData=x but i
can't seem to select the parent. (black page)
here the code:

Dim doc As XPathDocument = New
XPathDocument(Server.MapPath("Xml/LocationsTree.xml"))

Dim nav As XPathNavigator = doc.CreateNavigator()

nav.MoveToRoot()

nav.MoveToId("descendant::TREENODES[@NodeData='2']")


MoveToId method moves XPathNavigator to a node with specified ID.
"descendant::TREENODES[@NodeData='2']" doesn't look like ID.

Try
XPathNodeIterator ni =
nav.Select("/TREENODES/descendant::TreeNode[@NodeData='2']")
etc.
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com

Nov 12 '05 #3
Tamir Kamara wrote:
still i don't get any output on the page with this code:
Dim ni As XPathNodeIterator

ni = nav.Select("/TREENODES/descendant::TreeNode[@NodeData='2']")

Response.Write(ni.Current.GetAttribute("Text", ""))


You have to move XPathNodeIterator to get next selected node:
ni = nav.Select("/TREENODES/descendant::TreeNode[@NodeData='2']")
while (ni.MoveNext()
Response.Write(ni.Current.GetAttribute("Text", ""))

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #4

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

Similar topics

3
by: Peter Rohleder | last post by:
Hi, I'm using a style-sheet where I make use of the XPATH-"following-sibling"-expression. The part which makes problems looks similar to the following code: --------------------------- ...
2
by: Saurabh Sharma | last post by:
Hi, I am using Dom Parsing in Xml. I am the parent node and it has many children and each children has many children. I want to select children with a given name . Is there any method by which we...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
7
by: PatrickRThomas | last post by:
I need help selecting nodes while excluding some of them. Here's an example of XML: <my_xml> <all_items> <item> <key>1</key> <name>Item 1</name> </item> <item>
4
by: visu | last post by:
I need a solution to my problem. the problem is I ll have a button in page ... and when i click it .. content of a div tag has to be get selected (i.e what we normally do with mouse to...
0
by: Satiz | last post by:
Hi All, I've a TreeView(IE Webcontrol) and a DataGrid in my VS.Net 2003 ASP.Net web form. My problem : If i select a particular node(it may be parent, child or leaf), then the corresponding...
7
by: Thomas Schmidt | last post by:
Hi all, I need an XPath which selects all nodes of a specific name which start with a text node, i.e. I want the expression to select: <x> abcdefg <y>hijklmn</y> </x>
2
by: kooltop | last post by:
Server: DB2 LUW 9.5 on Solaris 10 Client: DB2 Data Server Client 9.5 (= Control Center) on a Win XP SP2 Problems: (1) Tools --Wizards -- "Backup Wizard" and press OK. In the next...
1
by: DeveloperX | last post by:
Hi, I should probably start with my XML as it makes it easier to explain the problem. <?xml version="1.0" encoding="utf-8" ?> <aa note="top level"> <b1 note="b1"> <c1 note="b1 c1"> <d1...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.