Reading XML

Posted on 2005-04-13
Last Modified: 2013-11-19
I don't know about everyone else, but I find the Help file in Visual Studio less than helpful, and no matter how I experiment, I can't find a way of reading an xml file through the VB Namespace xml.

I really wish to parse the file to return the value of some attribute or other -

- <Block name="fred">
     - <Attribute>
           <Value>likes to drink</Value>


How do "I return likes to drink" given "George"

as an example

Question by:broadbent
    LVL 28

    Expert Comment

    convert XML file to datset and then read dataset. It is the easiest way

    LVL 10

    Expert Comment

    Hi broadbent,

    you need to learn xpath, for a good tutorial try

    as for your question

    wait a mo

    LVL 10

    Accepted Solution


    Dim myDocument As New XmlDocument()
            myDocument.LoadXml("<?xml version=""1.0"" encoding=""ISO-8859-1""?><Block name=""fred""><Handle>1234</Handle><Attribute><Handle>2345</Handle><Tag>George</Tag><Value>likes to drink</Value></Attribute></Block>")
    LVL 4

    Author Comment

    Actually, I've said to hell with xml.
    Instead I read the whole file into a string, and then parse it myself. I am sure its much simpler and quicker.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    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.
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    737 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

    20 Experts available now in Live!

    Get 1:1 Help Now