Dim xmlDoc As New Msxml2.DOMDocument30
Dim objNodeList As IXMLDOMNodeList
xmlDoc.async = False
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("You have error " & myErr.reason)
Else
Dim str As String
str = ""
Set objNodeList = xmlDoc.getElementsByTagName("author")
For i = 0 To (objNodeList.length - 1)
str = str & objNodeList.Item(i).xml & vbCrLf
Next
MsgBox str
End If
Dim xmlDoc As New XmlDocument()
Dim nodelist as XmlNodeList
Dim strAuthors As String
xmlDoc.Load("books.xml")
nodeList = xmlDoc.GetElementsByTagName("author")
For Each node As XmlNode In nodeList
strAuthors &= node.Value & vbCrLf
Next
MsgBox (strAuthors)
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
</catalog>
Dim xmlDoc As New XmlDocument()
Dim nodelist As XmlNodeList
Dim strAuthors As String = ""
xmlDoc.Load("Data/Q_24151268.xml")
nodelist = xmlDoc.GetElementsByTagName("meta")
For Each node As XmlNode In nodelist
strAuthors &= node.FirstChild.Value & vbCrLf
Next
<?xml version="1.0" encoding="utf-8" ?>
<category name="IO">
<Subject name="Filehandling">
<Item id="1">
<Name>Enumerate Folders in a folder</Name>
<Reference></Reference>
<Imports>System.IO</Imports>
<Snippet>for each folder in folder next Folder
where kalle
order by pelle</Snippet>
<Restrictions>No recursive call fo folders</Restrictions>
<comment>This is comment 1</comment>
<New />
</Item>
<Item id="2">
<Name>Enumerate Files in a folder</Name>
<Reference></Reference>
<Imports>System.IO</Imports>
<Snippet>fors each file in folder next Folder</Snippet>
<Restrictions>No recursive call for files</Restrictions>
<comment>This is comment 2</comment>
<New />
</Item>
</Subject>
<Subject name="File properties">
<Item id="1">
<Name>Get file Created</Name>
<Reference></Reference>
<Imports>System.IO</Imports>
<Snippet>File.fileCreated</Snippet>
<Restrictions></Restrictions>
<comment>also you get other properties</comment>
<New />
</Item>
</Subject>
</category>
xmlDoc.Load("c:\XMLTest.xml")
catNodeList = xmlDoc.GetElementsByTagName("Category")
For i = 0 To catNodeList.Count - 1
catName = catNodeList(i).Attributes("Name").Value
Next i
xmlDoc.Load("c:\XMLTest.xml")
catNodeList = xmlDoc.GetElementsByTagName("Category")
For i = 0 To catNodeList.Count - 1
catName = catNodeList(i).Attributes("Name").Value
XmlNodeList genres = catNodeList(i).GetElementsByTagName("Subject")
' do something with genre nodes '
For Each genre As Node in genres
Dim genreName As String = genre.Attributes("Name").Value
Next
Next i
Dim xmlDoc As New XmlDocument()
Dim catNodeList As XmlNodeList
Dim genres As XmlNodeList
Dim catName As String
Dim i As Integer
Dim strFileName As String = "..\..\XMLTest.xml"
xmlDoc.Load(strFileName)
catNodeList = xmlDoc.GetElementsByTagName("Category")
For i = 0 To catNodeList.Count - 1
catName = catNodeList(i).Attributes("Name").Value
genres = catNodeList(i).GetElementsByTagName("Subject")
' do something with genre nodes '
For Each genre As Node In genres
Dim genreName As String = genre.Attributes("Name").Value
Next
Next i