Sys.Net.XmlHttpExecutor xml Property
Returns an XMLDOM object that contains the XML response from the browser's XMLHTTP object.
Note
To get or set property values for client API properties, you must call property accessor methods that are named with the get_ and set_ prefixes. For example, to get or set a value for a property such as cancel, you call the get_cancel or set_cancel methods.
var xml = MyExecutor.get_xml();
Exceptions
Exception type |
Condition |
---|---|
The xml property was accessed outside the event handler. -or- The xml property was accessed after the completed event occurred. |
Remarks
When the response text sent from the server is valid XML, the executor can convert it into an XMLDOM object. If the executor is unable to convert the response text into an XMLDOM object, it returns null.
Note
With Microsoft Internet Explorer, the executor explicitly sets the selection language of the XMLDOM instance to XPath. The returned XMLDOM object has character-encoding behavior specific to the browser's XMLHTTP implementation. This property is overridden from the base class implementation.
You can use the xml property only in code that is running inside a completed event handler, or running in the call stack of the completed event handler. An exception is thrown if you use the xml property when the executor did not return successfully, or if the XmlHttpExecutor.get_responseAvailable method returns false. An exception is also thrown if you use the xml property after the completed event has occurred. This is because the executor has released its reference to the browser's XMLHTTP object.
Example
The following example shows how to use the xml property. This code is part of a complete example found in the Sys.Net.XmlHttpExecutor class overview.
// This is the event handler called after
// the Web request returns. It is designed
// for Web requests that return XML.
function OnSucceededXml(executor, eventArgs)
{
if (executor.get_responseAvailable())
{
// Display XML.
if (document.all)
resultElementId.innerText += executor.get_xml().xml;
else
// Firefox
resultElementId.textContent += "First node: " +
executor.get_xml().documentElement.nodeName;
}
else
{
if (executor.get_timedOut())
alert("Timed Out");
else
if (executor.get_aborted())
alert("Aborted");
}
}
See Also
Reference
Sys.Net.WebRequestManager Class
Sys.Net.WebRequestExecutor Class