Go to index number in XML file

Posted on 2006-04-07
Last Modified: 2010-04-23
I am new to xml and 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

<Resources> <--------------------------------(Index1)

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

Question by:troyhalsey
    LVL 48

    Accepted Solution


    Author Comment

    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?
    LVL 11

    Assisted Solution

    ok heres a simplified version using xpath in

    '----------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("None Found..")
    end if
    '----------END CODE----------'


    Author Comment

    No objection, I will repost when I am ready to readdress the issue.  Thank you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    It’s quite interesting for me as I worked with Excel using 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 …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now