Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
Represents the top level of the XML source. Includes members for retrieving and creating all other XML objects.
Methods
The following table shows the methods for DOMDocument.
Method | Description |
---|---|
Aborts an asynchronous download in progress. |
|
Appends newChildas the last child of this node. |
|
Creates a new node that is an exact clone of this node. |
|
Creates a new attribute with the specified name. |
|
Creates a CDATA section node that contains the supplied data. |
|
Creates a comment node that contains the supplied data. |
|
Creates an empty IXMLDOMDocumentFragmentobject. |
|
Creates an element node using the specified name. |
|
Creates a new IXMLDOMEntityReferenceobject. |
|
Creates a node using the supplied type, name, and namespace. |
|
Creates a processing instruction node that contains the supplied target and data. |
|
Creates a text node that contains the supplied data. |
|
Returns a collection of elements that have the specified name. |
|
Returns True if this node has children. |
|
Inserts a child node to the left of the specified node or at the end of the list. |
|
load* |
Loads an XML document from the specified location. |
Loads an XML document using the supplied string. |
|
Returns the node whose identifier attribute matches the supplied value. |
|
Removes the specified child node from the list of children and returns it. |
|
Replaces the specified old child node with the supplied new child node in the set of children of this node, and returns the old child node. |
|
save* |
Saves an XML document to the specified location. |
Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes. |
|
Applies the specified pattern-matching operation to this node's context and returns the first matching node. |
|
Processes this node and its children using the supplied Extensible Stylesheet Language Transformations (XSLT) style sheet and returns the resulting transformation. |
|
Processes this node and its children using the supplied XSLT style sheet and returns the resulting transformation in the supplied object. |
* denotes an extension to the W3C DOM.
Properties
The following table shows the properties for DOMDocument.
Property | Description |
---|---|
Indicates whether asynchronous download is permitted. Read/write. |
|
Contains the list of attributes for this node. Read-only. |
|
Returns the base name for the name qualified with the namespace. Read-only. |
|
Contains a node list containing the children (for nodes that can have children). Read-only. |
|
Specifies the data type for this node. Read/write. |
|
Returns the definition of the node in the document type definition (DTD) or schema. Read-only. |
|
Contains the document type node that specifies the DTD for this document. Read-only. |
|
Contains the root element of the document. Read/write. |
|
Contains the first child of this node. Read-only. |
|
Contains the IXMLDOMImplementationobject for this document. Read-only. |
|
Returns the last child node. Read-only. |
|
Returns the Uniform Resource Identifier (URI) for the namespace. Read-only. |
|
Contains the next sibling of this node in the parent's child list. Read-only. |
|
Contains the qualified name of the element, attribute, or entity reference, or a fixed string for other node types. Read-only. |
|
Specifies the XML Document Object Model (DOM) node type, which determines valid values and whether the node can have child nodes. Read-only. |
|
Contains this node's value, expressed in its defined data type. Read/write. |
|
Returns the node type in string form. Read-only. |
|
Contains the text associated with the node. Read/write. |
|
Specifies the event handler for the ondataavailableevent. Read/write. |
|
Specifies the event handler to be called when the readyStateproperty changes. Read/write. |
|
Specifies the event handler for the ontransformnodeevent. Read/write. |
|
Returns the root of the document that contains this node. Read-only. |
|
Contains the parent node (for nodes that can have parents). Read-only. |
|
Contains True if this node and all descendants have been parsed and instantiated; False if any nodes remain to be parsed. Read-only. |
|
Returns an IXMLDOMParseErrorobject that contains information about the last parsing error. Read-only. |
|
Returns the namespace prefix. Read-only. |
|
Contains True if default processing preserves white space; False otherwise. Read/write. |
|
Contains the left sibling of this node. Read-only. |
|
Indicates the current state of the XML document. Read-only. |
|
Indicates whether external definitions (resolvable namespaces, DTD external subsets, and external entity references) are to be resolved at parse time, independent of validation. Read/write. |
|
Indicates whether the node (usually an attribute) is explicitly specified or derived from a default value in the DTD or schema. Read-only. |
|
text* |
Contains the text content of the node and its subtrees. Read/write. |
url* |
Returns the canonicalized URL for the last loaded XML document. Read-only. |
Indicates whether the parser should validate this document. Read/write. |
|
xml* |
Contains the XML representation of the node and all its descendants. Read-only. |
* denotes an extension to the World Wide Web Consortium (W3C) DOM.
Events
The following table shows the events for DOMDocument.
Event | Description |
---|---|
Indicates that XML document data is available. |
|
Indicates when the readyStateproperty changes. |
|
Fires before each node in the style sheet is applied to each node in the XML source. The ontransformnodeevent does not fire on DOMDocumentfor style sheets using the XSLT namespace. It does, however, fire on DOMDocumentfor style sheets using the XSL namespace. |
* denotes an extension to the W3C DOM.
Remarks
DOMDocumentrepresents the top node in the tree. It implements all of the base Document Object Model (DOM) document methods and provides additional members that support Extensible Stylesheet Language (XSL) and XML transformations.
Only one object can be created: the document. All other objects are accessed or created from the document.
The document can be created using a rental-threaded model. The document-threading model is set by the following settings.
Setting | Rental-threaded model |
---|---|
Version independent ProgID |
Msxml2.DOMDocument |
ProgID |
Msxml2.DOMDocument.3.0 |
ClassID |
F6D90F11-9C73-11D3-B32E-00C04F990BB4 |
VB Class Name |
DOMDocument30 |
In addition to the DOM interfaces, DOMDocumentimplements a number of standard COM interfaces. You can call the QueryInterfacemethod on DOMDocumentto get the following interfaces.
Interface | Usage |
---|---|
IUnknown |
DOMDocumentis a wrapper object and each query for DOMDocumentreturns a new wrapper. You should only compare IUnknowninterface pointers. |
IConnectionPointContainer |
Supports outgoing events ondataavailable Eventand onreadystatechange Eventthrough IPropertyNotifySink::OnChangedand IDispatch::Invoke. |
IDispatch |
Interface used by Visual Basic. |
IDispatchEx |
Interface used by dynamic late-bound scripting languages such as Microsoft® Visual Basic® Scripting Edition (VBScript) and Microsoft JScript® development system. This is not fully implemented. The following methods always return E_NOTIMPL: DeleteMemberByNameor DeleteMemberByDispID, GetMemberProperties, GetMemberName, GetNextDispID, and GetNameSpaceParent. |
IObjectSafety |
When the SetInterfaceSafetyOptionsmethod is called with nonzero safety options, the Microsoft XML Parser (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 a COM container to send an OLECMDID_STOP command to stop an asynchronous download. |
IPersistMoniker |
Provides control over how to bind the XML document to persistent data. Both synchronous and asynchronous loading are supported using BindToStorageon the given IMoniker. Saveis not called; therefore the BindToStorage, IsDirty, and SaveCompletedmethods 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 ITypeInfofor the DOMDocument. |
IStream |
You can read and write directly to the document through the IStreamthat is returned. You cannot Seekduring a Writeoperation, 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 Writeon the stream. You can also use this to test the persistence of your current DOM document by calling "xmldoc1.save(xmldoc2)." The Savemethod uses this IStreaminterface. |
When the object-creation methods, such as createElement, are used on the document, nodes are created in the context of the document, the ow 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, using setAttributeNode).
This interface inherits from IXMLDOMNode.
Requirements
Header | msxml2.h, msxml2.idl |
Windows Embedded CE | Windows CE .NET 4.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |