Last active
March 9, 2023 11:03
-
-
Save adojos/7ae75e517e8831f3ea4b1ca3bc74c19f to your computer and use it in GitHub Desktop.
VBS: Load XML file using MSXML Parser #vbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' 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