This interface represents the top level of the XML source. It includes methods and properties to obtain or create all of the other XML DOM interfaces.
IXMLDOMDocument Methods
abort* Aborts an asynchronous download in progress. async* Indicates whether asynchronous download is permitted. createAttribute Creates a new attribute with the specified name. createCDATASection Creates a CDATA section node that contains the supplied data. createComment Creates a comment node that contains the supplied data. createDocumentFragment Creates an empty document fragment object. createElement Creates an element node using the specified name. createEntityReference Creates a new entity reference object. createNode* Creates a node using the supplied type, name, and namespace. createProcessingInstruction Creates a processing instruction node that contains the supplied target and data. createTextNode Creates a text node that contains the supplied data. doctype Contains the document type node that specifies the DTD for this document. documentElement Contains the root element of the document. getElementsByTagName Returns a collection of elements that have the specified name. implementation Contains a pointer to the IXMLDOMImplementation object for this document. load* Loads an XML document from the specified location. loadXML* Loads an XML document using the supplied string. nodeFromID* Returns the node whose ID attribute matches the supplied value. ondataavailable* Event that fires when data is available for processing. ondataavailable* Property that specifies the event handler for the ondataavailable event. onreadystatechange* Event handler run when the readyState property changes. onreadystatechange* Property that specifies the event handler to be run when the readyState property changes. ontransformnode* Event handler run before each node of the XSL style sheet is applied to each node of the XML data source. ontransformnode* Property that specifies the event handler to be run when transformNode is called. parseError* Returns an IXMLDOMParseError object that contains information about the last parsing error. preserveWhiteSpace* Indicates whether to preserve all white space in the XML document. save* Saves the XML document to the specified location. readyState* Indicates the current state of the XML document. resolveExternals* Indicates that external definitions (resolvable namespaces, DTD external subsets, and external entity references) are to be resolved at parse time. url* Returns the canonicalized URL for the last loaded XML document. validateOnParse* Indicates whether the parser should validate this document. * denotes an extension to the W3C DOM.
Remarks
IXMLDOMDocument represents the top node in the tree. It implements all the base DOM document methods and provides additional methods and properties that support XSL and XML transformations.
You can create the IXMLDOMDocument object and query for the other interfaces as follows:
HRESULT hr; IXMLDOMDocument * pXMLDoc; IXMLDOMNode * pXDN; //... hr = CoInitialize(NULL); // check the return value, hr... hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (void**)&pXMLDoc); // check the return value, hr... hr = pXMLDoc->QueryInterface(IID_IXMLDOMNode, (void **)&pXDN); // check the return valueAlthough there are many interfaces, there is only one object that is created: the document. All other interfaces are accessed or created from the document.
The document can be created using either a free-threaded or a rental threading model. The behavior of the two models is identical; rental-threaded documents exhibit better performance because the parser need not manage concurrent access among threads. Note that you cannot combine nodes or documents that are created using differing threading models. The document threading model is determined by the following settings.
Setting Rental-threaded model Free-threaded model Version Independent ProgID Microsoft.XMLDOM Microsoft.FreeThreadedXMLDOM ProgID Microsoft.XMLDOM.1.0 Microsoft.FreeThreadedXMLDOM.1.0 ClassID 2933BF90-7B36-11D2-B20E-00C04F983E60 2933BF91-7B36-11D2-B20E-00C04F983E60 VB Class Name DOMDocument FreeThreadedDOMDocument In addition to the DOM interfaces, IXMLDOMDocument implements a number of standard OLE interfaces. You can call QueryInterface on the IXMLDOMDocument to get the following interfaces:
Interface Information
Interface Usage IUnknown IXMLDOMDocument is a wrapper object and each query for IXMLDOMDocument returns a new wrapper. It is recommended that you only compare IUknown interface pointers. IConnectionPointContainer Supports outgoing events OnDataAvailable and OnReadyStateChange through IPropertyNotifySink::OnChanged and IDispatch::Invoke. IDispatch Interface used by Visual Basic. IDispatchEx Interface used by dynamic late-bound scripting languages such as VBScript and JScript. This is not fully implemented. The following methods always return E_NOTIMPL: DeleteMemberByName or DeleteMemberByDispID, GetMemberProperties, GetMemberName, GetNextDispID, and GetNameSpaceParent. IMarshal Can be used to get a FreeThreadedMarshaler for a free threaded DOM document. This allows the free threaded DOM document to be used in ASP shared Session and Application state for sharing XML documents accross multiple clients in memory. IObjectSafety When the SetInterfaceSafteyOptions method is called with non-zero safety options, MSXML will apply security rules before fetching XML data. IObjectWithSite Enables a host application to provide extra contextual information such the base URL. IOleCommandTarget Used by an OLE container to send an OLECMDID_STOP command to stop an asyncronous download. IPersistMoniker Provides control over how to bind the XML document to persistent data. Both Syncronous and asyncronous loading are supported using BindToStorage on the given IMoniker. Save is not called, therefore BindToStorage, IsDirty, and SaveCompleted methods return E_NOTIMPL. IPersistStream Used to save and load the XML document to and from an IStream. IPersistStreamInit Updated version of IPersistStream. IProvideClassInfo Provides an easy way to get ITypeInfo for the DOMDocument. IStream You can read and write directly to the document via the IStream that is returned. You cannot Seek during a Write operation and the following methods are not implemented on this stream: SetSize, CopyTo, Commit, Revert, LockRegion, UnlockRegion, and Clone. This allows you to build an XML document efficiently by providing chunks of XML and calling Write on the stream. You can also use this to test the persistence of your current DOM document by calling "xmldoc1.save(xmldoc2)". The Save method uses this IStream interface. When the object-creation methods (such as createElement) are used on the document, nodes are created in the context of the document (the ownerDocument property of the node points to the document) but the node is not part of the document tree. The node is only part of the document tree when it is explicitly added to the tree by calling insertBefore, replaceChild, or appendChild (or, for attributes, setAttributeNode).
Interface Information
Implementation Msxml.dll Inherits from IXMLDOMNode Header and IDL files Msxml.h, Xmldom.idl Minimum availability Internet Explorer 5 Minimum operating systems Windows 95, Windows NT