Loads an XML document from the specified location.
boolValue = oXMLDOMDocument.load(xmlSource);
Boolean. Returns True if the load succeeded; False if the load failed.
The following script example creates a DOMDocument
object and uses the load
method to load a local XML file.
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0"); xmlDoc.async = false; xmlDoc.load("C:\\temp\\books.xml"); if (xmlDoc.parseError.errorCode <> 0) { var myErr = xmlDoc.parseError; alert("You have error " + myErr.reason); } else { alert(xmlDoc.xml); }
boolValue = oXMLDOMDocument.load(xmlSource)
Boolean. Returns True if the load succeeded; False if the load failed.
The following Microsoft Visual Basic® example creates a DOMDocument
object and uses the load
method to load a local XML file.
Dim xmlDoc As New Msxml2.DOMDocument50 xmlDoc.async = False xmlDoc.Load ("C:\temp\books.xml") If (xmlDoc.parseError.errorCode <> 0) Then Dim myErr Set myErr = xmlDoc.parseError MsgBox("You have error " & myErr.reason) Else MsgBox xmlDoc.xml End If
HRESULT load( VARIANT xmlSource, VARIANT_BOOL *isSuccessful);
IStream
, SAFEARRAY of bytes (VT_ARRAY|VT_UI1), a DOMDocument
object, or any object that supports IStream
, ISequentialStream
, or IPersistStream
. See Remarks for more information.isSuccessful
parameter is Null.If the URL cannot be resolved or accessed or does not reference an XML document, this method returns an error and sets the documentElement
property of the DOMDocument
to Null.
The load
method can also take any object that supports IStream
and the Microsoft® Internet Information Services (IIS) Request
object.
Calling load
or loadXML
on an existing document immediately discards the content of the document.
If loading an XML document from a resource, the load must be performed asynchronously or the load will fail. For example:
Set objXML = CreateObject("Msxml2.DOMDocument.5.0") ObjXML.async=true objXML.load "res://msxml.dll/DEFAULTSS.XSL" if (xmlDoc.parseError.errorCode <> 0) { var myErr = xmlDoc.parseError; alert("You have error " + myErr.reason); } else { WScript.echo objXML.parseError.reason objXML.save "c:\defaultss.xsl" }
You can use this method to check if the loaded XML document is well-formed. You cannot use it to validate the XML document against a schema.
This member is an extension of the World Wide Web Consortium (W3C) Document Object Model (DOM).
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.
documentElement Property | loadXML Method | Persistence and the DOM
Applies to: DOMDocument