Compartir a través de


del método _XDocument2.CreateDOM

Crea una nueva instancia del Modelo de objetos de documento (DOM) XML en memoria.

Espacio de nombres:  Microsoft.Office.Interop.InfoPath.SemiTrust
Ensamblado:  Microsoft.Office.Interop.InfoPath.SemiTrust (en Microsoft.Office.Interop.InfoPath.SemiTrust.dll)

Sintaxis

'Declaración
Function CreateDOM As IXMLDOMDocument
'Uso
Dim instance As _XDocument2
Dim returnValue As IXMLDOMDocument

returnValue = instance.CreateDOM()
IXMLDOMDocument CreateDOM()

Valor devuelto

Tipo: Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMDocument
IXMLDOMDocument de la nueva instancia del Modelo de objetos de documento (DOM) XML.

Comentarios

Utilizar el método CreateDOM para crear una instancia del XML DOM es equivalente a usar el siguiente método de creación de un objeto DOMDocument de Microsoft XML Core Services (MSXML) 5.0:

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

Importante

Únicamente se puede acceder a este miembro con formularios que se ejecuten en el mismo dominio que el formulario que está actualmente abierto o con formularios a los que se hayan concedido permisos entre dominios.

Nota

Al automatizar InfoPath, el método setProperty del objeto IXMLDOMDocument2 podría fallar para los orígenes de datos secundarios. Para utilizar el método setProperty, siga este ejemplo:

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

Ejemplos

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

Vea también

Referencia

interfaz _XDocument2

Miembros _XDocument2

Espacio de nombres Microsoft.Office.Interop.InfoPath.SemiTrust