Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

xml Property1


Contains the XML representation of the node and all its descendants.

strValue = oXMLDOMNode.xml;  


The following script example creates an IXMLDOMNode of type NODE_ENTITY, and then displays the object's XML value, including that of any of the object's child nodes.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var currNode;
xmlDoc.async = false;
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   currNode = xmlDoc.documentElement.childNodes.item(0);

strValue = oXMLDOMNode.xml  

HRESULT get_xml(  
    BSTR *xmlString);  


xmlString[out, retval]
An XML representation of this node and all its descendants.

C/C++ Return Values

The value returned if successful.

The value returned if the xmlString property is Null.

The property is read-only.

The xml property always returns a Unicode string. That is, the xml property for DOMDocument converts the document from its original encoding to Unicode. As a result, the original encoding attribute is removed. For example, <?xml version="1.0" encoding="UTF-8"?> appears in the xml property as follows.

<?xml version="1.0"?>  

If the original encoding was not removed by the xml property, the following line returns an error indicating the parser cannot switch from Unicode to UTF-8 encoding.


If you use the save method, the original encoding is preserved. For example, if you load a document in Microsoft® Windows® 1252 encoding, it will be saved in that format.

This value depends on the value of the nodeType property.









Returns the string representation of the node and all its descendants.
NODE_DOCUMENT_FRAGMENTReturns the string representation of all descendant nodes of the document fragment.
NODE_DOCUMENT_TYPEReturns the string representation of the <!DOCTYPE ...> declaration, including the internal subset if specified.
NODE_ENTITY_REFERENCEReturns the string representation of the entity reference. Although the entity reference has children, they are not returned.

This member is an extension of the World Wide Web Consortium (W3C) Document Object Model (DOM).

Implemented in:

MSXML 2.0 and later

IXMLDOMAttribute | IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMDocument-DOMDocument | IXMLDOMDocumentFragment | IXMLDOMDocumentType | IXMLDOMElement | IXMLDOMEntity | IXMLDOMEntityReference | IXMLDOMNode | IXMLDOMNotation | IXMLDOMProcessingInstruction | IXMLDOMText

nodeType Property1
save Method (DOMDocument)
Persistence and the DOM

© 2017 Microsoft