?
Solved

Go to index number in XML file

Posted on 2006-04-07
6
Medium Priority
?
163 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:troyhalsey
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
Mikal613 earned 1000 total points
ID: 16404985
0
 

Author Comment

by:troyhalsey
ID: 16419755
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
 
LVL 11

Assisted Solution

by:coopzz
coopzz earned 1000 total points
ID: 16423554
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
 

Author Comment

by:troyhalsey
ID: 16605746
No objection, I will repost when I am ready to readdress the issue.  Thank you.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question