Skip to content

Instantly share code, notes, and snippets.

@adojos
Last active March 9, 2023 11:03
Show Gist options
  • Save adojos/7ae75e517e8831f3ea4b1ca3bc74c19f to your computer and use it in GitHub Desktop.
Save adojos/7ae75e517e8831f3ea4b1ca3bc74c19f to your computer and use it in GitHub Desktop.
VBS: Load XML file using MSXML Parser #vbs
' This ParseError property is for errors and warnings during 'Load'method.
' Applies to IXMLDOMParseError interface.
Public Function LoadXML(strXmlPath)
Dim ObjParseErr, ObjXML
Dim IsWait
Set ObjXML = CreateObject ("MSXML2.DOMDocument.6.0")
' WScript.Echo("Microsoft XML Core Services (MSXML) 6.0 is not installed.\n"
' +"Download and install MSXML 6.0 from http://msdn.microsoft.com/xml\n"
' +"before continuing.");
With ObjXML
'Set First Level DOM Properties
.async = False
.validateOnParse = False
.resolveExternals = False
End With
ObjXML.Load (strXmlPath)
Set ObjError = ObjXML.parseError
With ObjError
If .errorCode <> 0 Then
msgbox "XML Document could not be loaded!!!" & vbCrLf &_
"ErrorCode: " & .errorCode & vbCrLf &_
"Line: " & .line & vbCrLf &_
"Reason: " & .reason & vbCrLf &_
"Path: " & .URL
Else
msgbox "XML Loaded Successfully!"
Set LoadXML = ObjXML
End If
End With
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment