How to read an XML File

后端 未结 2 1062
-上瘾入骨i
-上瘾入骨i 2020-12-07 05:28

I have a VB.net program. I\'m attempting to use XMLReader to read a .xml file. I want to break the XML File up to organize it into different \"Sections\" In this example

2条回答
  •  被撕碎了的回忆
    2020-12-07 06:15

    Check out this example. http://msdn.microsoft.com/en-us/library/dc0c9ekk.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2

    You should can use:

    doc.GetElementsByTagName("FormTitle")
    

    You can then loop through all of the child nodes. http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.childnodes.aspx

        Dim root As XmlNode = doc.GetElementsByTagName("FormTitle").Item(1)
    
        'Display the contents of the child nodes. 
        If root.HasChildNodes Then 
            Dim i As Integer 
            For i = 0 To root.ChildNodes.Count - 1
                Console.WriteLine(root.ChildNodes(i).InnerText)
            Next i
        End If 
    

提交回复
热议问题