Share via


_XDocument3.CreateDOM method

Creates a new instance of the XML Document Object Model (DOM) in memory.

Namespace:  Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly:  Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.dll)

Syntax

'Declaration
Function CreateDOM As IXMLDOMDocument
'Usage
Dim instance As _XDocument3
Dim returnValue As IXMLDOMDocument

returnValue = instance.CreateDOM()
IXMLDOMDocument CreateDOM()

Return value

Type: Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMDocument
An IXMLDOMDocument that can be accessed from a new instance of the XML Document Object Model (DOM).

Implements

_XDocument2.CreateDOM()

Remarks

Using the CreateDOM method to create an instance of the XML DOM is equivalent to using the following method of creating a Microsoft XML Core Services (MSXML) 5.0 DOMDocument object:

var objDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");

Important

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

Note

When automating InfoPath, the setProperty method of the IXMLDOMDocument2 object may fail for secondary data sources. To use the setProperty method, follow this example:

IXMLDOMDocument2 myDocument = (IXMLDOMDocument2) thisXDocument.CreateDOM();
myDocument.setProperty("SelectionNameSpaces",namespaceString);

Examples

// create a new XMLDOMDocument that can be used by InfoPath
IXMLDOMDocument newDOM = thisXDocument.CreateDOM();
// Get one node from the main DOM and add it to the new DOM
IXMLDOMNode referenceNode = thisXDocument.DOM.selectSingleNode("//my:group1");
newDOM.appendChild(referenceNode);
// create a new node that will be added to the new DOM
IXMLDOMNode newNode = newDOM.createNode(1,"my:Group2",referenceNode.namespaceURI);
// Set its value
newNode.text = "this is a group2 node";
// Set the SelectionNamespaces attribute with the namespace used in the new DOM
((IXMLDOMDocument2)newDOM).setProperty("SelectionNamespaces","xmlns:my='" + referenceNode.namespaceURI + "'");
// Select one mode from the new DOM and add the new Node as its child
IXMLDOMNode parentNode = newDOM.selectSingleNode("//my:group1");
parentNode.appendChild(newNode);

See also

Reference

_XDocument3 interface

_XDocument3 members

CreateDOM overload

Microsoft.Office.Interop.InfoPath.SemiTrust namespace