Freigeben über


_XDocument2.CreateDOM-Methode

Erstellt im Speicher eine neue Instanz von XML-DOM (Document Object Model).

Diese Methode ist nicht CLS-kompatibel.  

Namespace: Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly: Microsoft.Office.Interop.InfoPath.SemiTrust (in microsoft.office.interop.infopath.semitrust.dll)

Syntax

<DispIdAttribute(48)> _
Function CreateDOM As IXMLDOMDocument

Dim instance As _XDocument2
Dim returnValue As IXMLDOMDocument

returnValue = instance.CreateDOM
[DispIdAttribute(48)] 
IXMLDOMDocument CreateDOM ()

Rückgabewert

Ein IXMLDOMDocument-Element der neuen Instanz von XML-DOM (Document Object Model).

Hinweise

Die Verwendung der CreateDOM-Methode zum Erstellen einer Instanz von XML-DOM entspricht der Verwendung der folgenden Methode zum Erstellen eines DOMDocument-Objekts von Microsoft XML Core Services (MSXML) 5.0:

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

Auf den Member kann nur über Formulare zugegriffen werden, die in derselben Domäne wie das zurzeit geöffnete Formular ausgeführt werden, oder über Formulare, denen domänenübergreifende Berechtigungen erteilt wurden.

Hinweis:

Beim Automatisieren von InfoPath schlägt die setProperty-Methode des IXMLDOMDocument2-Objekts für sekundäre Datenquellen möglicherweise fehl. Führen Sie zur Verwendung der setProperty-Methode das folgende Beispiel aus:

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

Beispiel

// 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);

Siehe auch

Referenz

_XDocument2-Schnittstelle
_XDocument2-Member
Microsoft.Office.Interop.InfoPath.SemiTrust-Namespace