loadXML method (XMLDocument)
Builds an XMLDocument object from the specified string.
The loadXML method resets the XMLDocument object first (clears the document represented by the XMLDocument object, resets the XMLDOMParseError property, etc.) and starts to load the specified text. This method is useful if you have an XML formatted text and you need to handle it as an XML document.
For example, when an XML document is downloaded with the XMLHttpRequest object, the responseXML property of the XMLHttpRequest object refers to an XMLDocument object that represents the downloaded content. If the downloaded content is not well-formed or the character encoding was detected wrong, the responseXML property refers to an XMLDocument object that describes the error. In that case, you can use the responseText property of the XMLHttpRequest object and the loadXML method to build an XMLDocument object 'manually'.In Firefox, Opera, Google Chrome, Safari and Internet Explorer from version 9, the parseFromString method provides similar functionality to the loadXML method. See the example and the ParseHTTPResponse method in the attached ajax.js file of the example below for details.
You can find the related objects in the Supported by objects section below.
|String that specifies the contents of the XML file.|
Boolean. One of the following values:
|The loading failed. Use the XMLDOMParseError property to get information about the error. The documentElement property is set to null in that case.|
|The loading was successful.|
Example HTML code 1:
This example illustrates the use of the loadXML and the parseFromString methods:
Did you find this example helpful?
User Contributed Comments