tags:

views:

29

answers:

2

I have this bit of code:

typedef CComQIPtr<MSXML::IXMLDOMDocument2> XML_DocumentPtr;

then inside some class:

XML_DocumentPtr m_spDoc;

then inside some function:

XML_NodePtr rn=m_spDoc->GetdocumentElement();

I cannot find anywhere in the MSDN documentation what that GetDocumentElement() is supposed to do? Can anyone tell me why it doesn't seem to be part of IXMLDOMDocument2 interface?

And which interface does have it?

+2  A: 

IXMLDocument2 inherits from IXMLDocument. The GetDocumentElement() method is defined in that interface. See here.

Basically GetdocumentElement returns the root element of the XML document.

The property is read/write. It returns an IXMLDOMElement that represents the single element that represents the root of the XML document tree. It returns Null if no root exists.

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 insertBefore method of theIXMLDOMNode.

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

smink
A: 

GetdocumentElement returns the root element of the document or NULL if no root exists.

Babak Ghahremanpour