|
|
Title | Find nodes with a particular tag name in an XML file with VB .NET |
Description | This example shows how to find nodes with a particular tag name in an XML file with VB .NET. |
Keywords | XML, VB.NET, find node |
Categories | Office |
|
|
This program creates an XmlDocument object and uses its Load method to load the XML file. It then uses the object's GetElementsByTagName to get a list of XmlNode objects that have the indicated name. It loops through those objects, processing them. In this example, the program displays each object's Name attribute and its tag value.
|
|
' Load the XML file.
Dim xml_doc As New Xml.XmlDocument
xml_doc.Load(txtFile.Text)
' Get the desired children.
Dim child_nodes As XmlNodeList = _
xml_doc.GetElementsByTagName(txtTagName.Text)
' Process the children.
Dim txt As String = ""
For Each child As XmlNode In child_nodes
txt &= _
child.Attributes("Name").InnerXml & " = " & _
child.InnerText & vbCrLf
Next child
txtResults.Text = txt
|
|
|
|
|
|