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

Path of an XML node

Hi,
how do I get the path of an XML node?

I have:

Dim xmlNo As XmlNode = xml.SelectSingleNode("//Category[@Id='" & CategoryID
& "']")

I want to get the path of the xmlNo:

i.e.
Categories\Video games\Nintendo 64\Games\

thanks,
Bruno
Nov 12 '05 #1
4 5158
"The Clansman" <Not His Real Name> wrote in message news:ef**************@TK2MSFTNGP12.phx.gbl...
I want to get the path of the xmlNo:

i.e.
Categories\Video games\Nintendo 64\Games\


I take it there is a Categories node beneath Games that is the one
you selected? (btw, element names can't include spaces.)

- - - ParentNodePath.vb (excerpt)
' . . .
Dim xn As XmlNode = xmlDoc.SelectSingleNode( "//Category")
If ( xn Is Not Nothing ) Then
' Import StringBuilder from System.Text
Dim buf As StringBuilder = New StringBuilder( 256)
xn = xn.ParentNode
While ( ( xn Is Not Nothing ) And ( xn.ParentNode Is Not Nothing ) )
buf.Insert( 0, '\')
buf.Insert( 0, xn.Name)
n = n.ParentNode
End While
End If
Dim parentPath As String = buf.ToString( )
' . . .
- - -

Assuming it finds a Category element in a node tree resembling your
example, parentPath will easily contain:

Categories\VideoGames\Nintendo64\Games\
Derek Harmon
Nov 12 '05 #2
"The Clansman" <Not His Real Name> wrote in message news:ef**************@TK2MSFTNGP12.phx.gbl...
I want to get the path of the xmlNo:

i.e.
Categories\Video games\Nintendo 64\Games\


I take it there is a Categories node beneath Games that is the one
you selected? (btw, element names can't include spaces.)

- - - ParentNodePath.vb (excerpt)
' . . .
Dim xn As XmlNode = xmlDoc.SelectSingleNode( "//Category")
If ( xn Is Not Nothing ) Then
' Import StringBuilder from System.Text
Dim buf As StringBuilder = New StringBuilder( 256)
xn = xn.ParentNode
While ( ( xn Is Not Nothing ) And ( xn.ParentNode Is Not Nothing ) )
buf.Insert( 0, '\')
buf.Insert( 0, xn.Name)
n = n.ParentNode
End While
End If
Dim parentPath As String = buf.ToString( )
' . . .
- - -

Assuming it finds a Category element in a node tree resembling your
example, parentPath will easily contain:

Categories\VideoGames\Nintendo64\Games\
Derek Harmon
Nov 12 '05 #3
Thanks man!!

yes, its VideoGames

Bruno

"Derek Harmon" <lo*******@msn.com> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
"The Clansman" <Not His Real Name> wrote in message news:ef**************@TK2MSFTNGP12.phx.gbl...
I want to get the path of the xmlNo:

i.e.
Categories\Video games\Nintendo 64\Games\


I take it there is a Categories node beneath Games that is the one
you selected? (btw, element names can't include spaces.)

- - - ParentNodePath.vb (excerpt)
' . . .
Dim xn As XmlNode = xmlDoc.SelectSingleNode( "//Category")
If ( xn Is Not Nothing ) Then
' Import StringBuilder from System.Text
Dim buf As StringBuilder = New StringBuilder( 256)
xn = xn.ParentNode
While ( ( xn Is Not Nothing ) And ( xn.ParentNode Is Not

Nothing ) ) buf.Insert( 0, '\')
buf.Insert( 0, xn.Name)
n = n.ParentNode
End While
End If
Dim parentPath As String = buf.ToString( )
' . . .
- - -

Assuming it finds a Category element in a node tree resembling your
example, parentPath will easily contain:

Categories\VideoGames\Nintendo64\Games\
Derek Harmon

Nov 12 '05 #4
Thanks man!!

yes, its VideoGames

Bruno

"Derek Harmon" <lo*******@msn.com> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
"The Clansman" <Not His Real Name> wrote in message news:ef**************@TK2MSFTNGP12.phx.gbl...
I want to get the path of the xmlNo:

i.e.
Categories\Video games\Nintendo 64\Games\


I take it there is a Categories node beneath Games that is the one
you selected? (btw, element names can't include spaces.)

- - - ParentNodePath.vb (excerpt)
' . . .
Dim xn As XmlNode = xmlDoc.SelectSingleNode( "//Category")
If ( xn Is Not Nothing ) Then
' Import StringBuilder from System.Text
Dim buf As StringBuilder = New StringBuilder( 256)
xn = xn.ParentNode
While ( ( xn Is Not Nothing ) And ( xn.ParentNode Is Not

Nothing ) ) buf.Insert( 0, '\')
buf.Insert( 0, xn.Name)
n = n.ParentNode
End While
End If
Dim parentPath As String = buf.ToString( )
' . . .
- - -

Assuming it finds a Category element in a node tree resembling your
example, parentPath will easily contain:

Categories\VideoGames\Nintendo64\Games\
Derek Harmon

Nov 12 '05 #5

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

Similar topics

7
by: Eric.Jones | last post by:
I've encountered a strange error with loading delimited files from a Samba (SMB) network drive, has anyone else seen this before? (Platform: WinXP Pro, UDB PE 8015, level 02060106, SAMPLE db) ...
1
by: Norbert Munkel | last post by:
Hi, System: 8.1.5 UDB on SuSE Linux I created a new SMS tablespace with following ddl: CREATE REGULAR TABLESPACE ASNCTL IN DATABASE PARTITION GROUP IBMDEFAULTGROUP PAGESIZE 4096 MANAGED BY...
4
by: Andy Gilman | last post by:
I want a method basically that tells me if a path is a file or directory, or any other possibilities. What do i need to do? I'm hoping I dont have to manually determine all these things with...
13
by: André Nogueira | last post by:
Hi there. I know you can view a node's fullpath property, but is it posible to select a node using its path? Like, tell the treeview that the node that should be selected is the node with the...
2
by: Han Sen | last post by:
I'm building a treeview from an xml file. The node values point to various paths, some of which are network paths. Next to every node I'd like to display an "offline" image (if that the path is...
4
by: James L | last post by:
I have a tree view with a root, 3 noodes(1,2,3) each having one sub node. I drill down to a node. I get the path by saying treeView1.selectedNode.fullpath and assign it to a variable. If I...
2
by: James L | last post by:
I have finally developed some code that allows you to re populate a tree view and re select the last node that was clicked. However, you have to hard code it for the number of levels the tree view...
1
by: Zhiv Kurilka | last post by:
Dear all, supposed I have xml file root> <a> <name>ddd</name> <b> <name>ggg</name> <c>10</c> </b> </a>
5
by: Sharon | last post by:
How can I get the full XML path (as string) of a specific XmlNode ? -- Thanks Sharon
0
by: Pivot_Tables | last post by:
Please follow the below link as this post is continuation from the below post. http://groups.google.com/group/comp.databases.ibm-db2/browse_thread/thread/1589589ccf38eb0a Hi Guys, I got...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.