Go to index number in XML file

I am new to xml and vb.net...so I am probably misunderstanding this process but:

Is it possible to GoTo a specific node index based on a specific nodes value?

I have a list box that is populated by an xml file.  I want to be able to select an item in the list box...and have it GoTo...the corresponding index.

My a very simplified example of my xml file looks kind of like this

<ResourceBook>
<Resources> <--------------------------------(Index1)
<Resource>
<Name>Bob</Name>
</Resource>
<Resource><--------------------------------(Index2)
<Name>Frank</Name>
</Resource>
</Resources>
</ResourceBook>

So...if they select Bob in the listbox...I want currentresourceindex to be 1....how do I do this?

Troy
troyhalseyAsked:
Who is Participating?
 
Mikal613Commented:
0
 
troyhalseyAuthor Commented:
Yes, everyone has told me that.  I have books on xpath....I don't know how to begin using xpath.  Can you provide with a sample of how xpath interacts with vb code?
0
 
coopzzCommented:
ok heres a simplified version using xpath in vb.net

'----------Start Code----------'
        Dim oXML As New Xml.XmlDocument
        oXML.LoadXml("<?xml version='1.0'?><ResourceBook><Resources><Resource><Name>Bob</Name></Resource><Resource><Name>Frank</Name></Resource></Resources></ResourceBook>")

        Dim oNodeList As Xml.XmlNodeList = oXML.DocumentElement.SelectNodes("//Resource") 'grab all the Resource Nodes using xpath expression.
if (oNodeList.Count > 0) then
        MsgBox(oNodeList(1).InnerXml) 'grab the second one inner xml
        MsgBox(oNodeList(1).SelectSingleNode("Name").InnerText)
else
        msgbox("None Found..")
end if
'----------END CODE----------'

CooPzZ
0
 
troyhalseyAuthor Commented:
No objection, I will repost when I am ready to readdress the issue.  Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.