By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,761 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,761 IT Pros & Developers. It's quick & easy.

read xml file nodes

P: n/a
Sam
Hi,
I've got the following xml file:

<?xml version="1.0" encoding="utf-8" ?>
<ToolTip>
<table tag="some explanations about tables"/>
<view tag="some explanations about views"/>
</ToolTip>

and with the following code i'm trying to read a particular node :

Public Function LoadToolTip(ByVal Form As String, ByVal Tag As String)
As String
Dim xDoc As New XmlDocument
Try
Dim filePath As String = "../ToolTips/" & Form & ".xml"
xDoc.Load(filePath)
Dim xNodeList As XmlNodeList = xDoc.SelectNodes("/ToolTip/"
& Tag & "/@tag")
Return xNodeList.Item(0).Value
Catch ex As Exception
MsgBox(ex.ToString)
End Try
end function

But xNodeList is always empty and that leads to a crash. What am I
doing wrong when reading the node ?

Thx

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
value where if you put this way.... <view tag"...">value</view>

the way youre putting, you must to try to find it in an attribute value...

i think it was, xnodelist.item(0).attribute(0).value or something like that...
--
Salute by the First Time!
"Sam" wrote:
Hi,
I've got the following xml file:

<?xml version="1.0" encoding="utf-8" ?>
<ToolTip>
<table tag="some explanations about tables"/>
<view tag="some explanations about views"/>
</ToolTip>

and with the following code i'm trying to read a particular node :

Public Function LoadToolTip(ByVal Form As String, ByVal Tag As String)
As String
Dim xDoc As New XmlDocument
Try
Dim filePath As String = "../ToolTips/" & Form & ".xml"
xDoc.Load(filePath)
Dim xNodeList As XmlNodeList = xDoc.SelectNodes("/ToolTip/"
& Tag & "/@tag")
Return xNodeList.Item(0).Value
Catch ex As Exception
MsgBox(ex.ToString)
End Try
end function

But xNodeList is always empty and that leads to a crash. What am I
doing wrong when reading the node ?

Thx

Nov 21 '05 #2

P: n/a
Sam
I'm sorry could you explain again, I don't understand your reply ?
Thank you.

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.