Microsoft XML SDK 2.6 - XML Reference

IXMLDOMDocument::documentElement Method

IXMLDOMDocument::get_documentElement Method

Returns the root element of the document.

Visual Basic Syntax

Set objXMLDOMElement = oXMLDOMDocument.documentElement

C/C++ Syntax

HRESULT get_documentElement(
    IXMLDOMElement** DOMElement);

Parameters

DOMElement [out]
DOMElement object that represents the single element representing the root of the XML document tree. Returns Null if no root exists.

C/C++ Return Values

S_OK
Value returned if successful.
S_FALSE
Value returned if there is no document element.
E_INVALIDARG
Value returned if DOMElement is Null.


IXMLDOMDocument::putref_documentElement Method

Sets the root element of the document.

Visual Basic Syntax

Set objXMLDOMDocument.documentElement = objXMLDOMElement 

C/C++ Syntax

HRESULT putref_documentElement(
    IXMLDOMElement* DOMElement);

Parameters

DOMElement [in]
XMLDOMElement object that represents the single element that represents the root of the XML document tree. Returns Null if no root exists.

C/C++ Return Values

Returns S_OK if successful, or an error code otherwise.

Remarks

When setting the documentElement property, the specified element node is inserted into the child list of the document after any document type node. To precisely place the node within the children of the document, call the XMLDOMNode object's insertBefore method.

The parentNode property is reset to the document node as a result of this operation.

See Also

IXMLDOMDocument Interface