Private Sub cmdLoad_Click()
Dim xmlDoc
Dim xmlError
Dim xmlRootElement
Dim success As Boolean
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
' Allow the document to complete loading
xmlDoc.async = False
' Validate the document against a DTD
xmlDoc.validateOnParse = True
success = xmlDoc.Load("http://www.juicystudio.com/tutorial/xml/cd.xml")
If success = True Then
Set xmlRootElement = xmlDoc.documentElement
Me.txtXML = xmlRootElement.XML
Set xmlRootElement = Nothing
Else
Set xmlError = xmlDoc.parseError
Me.txtXML = "Error code: " & xmlError.errorCode & vbCrLf _
& "Reason: " & xmlError.reason & vbCrLf _
& "Source: " & vbCrLf & xmlError.srcText & vbCrLf _
& "URL: " & xmlError.url
Set xmlError = Nothing
End If
End Sub