Compartilhar via


_XDocument4.CreateDOM Método

Definição

Cria uma nova instância do DOM (Modelo de Objeto de Documento XML) na memória.

public:
 Microsoft::Office::Interop::InfoPath::Xml::IXMLDOMDocument ^ CreateDOM();
public Microsoft.Office.Interop.InfoPath.Xml.IXMLDOMDocument CreateDOM ();
abstract member CreateDOM : unit -> Microsoft.Office.Interop.InfoPath.Xml.IXMLDOMDocument
Public Function CreateDOM () As IXMLDOMDocument

Retornos

Um IXMLDOMDocument que pode ser acessado a partir de uma nova instância do DOM (Modelo de Objeto de Documento XML).

Implementações

Exemplos

// create a new XMLDOMDocument that can be used by InfoPath
IXMLDOMDocument newDOM = thisXDocument.<span class="label">CreateDOM</span>();
// 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
((IXMLDOMDocument3)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);
// create a new XMLDOMDocument that can be used by InfoPath
IXMLDOMDocument newDOM = thisXDocument.<span class="label">CreateDOM</span>();
// 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
((IXMLDOMDocument3)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);

Comentários

Usar o método CreateDOM para criar uma instância do DOM XML é equivalente ao uso do seguinte método de criação de um objeto DOMDocument de Microsoft XML Core Services (MSXML) 5.0:

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

Observação: ao automatizar o InfoPath, o método setProperty do objeto IXMLDOMDocument2 pode falhar para fontes de dados secundárias. Para usar o método setProperty , siga este exemplo:

IXMLDOMDocument3 myDocument = (IXMLDOMDocument3) thisXDocument.<span class="label">CreateDOM</span>();
myDocument.setProperty("SelectionNameSpaces",namespaceString);

Aplica-se a