Solved

Read XML node

Posted on 2006-10-20
3
343 Views
Last Modified: 2010-04-23
Hi,

Within my XML file I have the following node;

<Type>Hardware</Type>

I would like to store "Hardware" from Type node as a string

How do I get this, I have attempted to do;

        Dim XmlDoc As New XmlDocument
        XmlDoc.Load(SourceFileName)

        Dim lstNodes As XmlNodeList = XmlDoc.GetElementsByTagName("Type")

        Dim node As XmlNode
        For Each node In lstNodes
            MessageBox.Show(node.ToString)
        Next
0
Comment
Question by:nickmarshall
  • 3
3 Comments
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 125 total points
ID: 17773932
Try it with the InnerText property:

        Dim XmlDoc As New XmlDocument
        XmlDoc.Load("C:\Temp\Sample.xml")

        Dim lstNodes As XmlNodeList = XmlDoc.GetElementsByTagName("Type")

        For Each node As XmlNode In lstNodes
            MessageBox.Show(node.InnerText)
        Next
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 17773940
Note: I tested with the sample xml document, change the load statement to reflect your filename path again:

XmlDoc.Load("C:\Temp\Sample.xml")          to:

XmlDoc.Load(SourceFileName)

0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 17773994
sorry, this question seems to be indirectly related to your previous asked question that is still open, if this doesnt work for you then you can close one of the two questions by requesting a close here:

http://www.experts-exchange.com/Community_Support/

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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