Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

Read XML node

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
nickmarshall
Asked:
nickmarshall
  • 3
1 Solution
 
Ravi SinghSenior Software EngineerCommented:
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
 
Ravi SinghSenior Software EngineerCommented:
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
 
Ravi SinghSenior Software EngineerCommented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now