_XDocument3.CreateDOM Méthode

Définition

Crée une instance du modèle XML DOM (Document Object Model) en mémoire.

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

Retours

Un IXMLDOMDocument accessible depuis une nouvelle instance du modèle DOM (Document Object Model) XML.

Implémente

Exemples

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

Remarques

L'utilisation de la méthode CreateDOM pour créer une instance du modèle XML DOM est équivalente à l'utilisation de la méthode suivante de création d'un objet DOMDocument Microsoft XML Core Services (MSXML) 5.0 :

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

Important : ce membre est accessible uniquement par les formulaires s’exécutant dans le même domaine que le formulaire actuellement ouvert, ou par les formulaires auxquels des autorisations inter-domaines ont été accordées.

Remarque : Lors de l’automatisation d’InfoPath, la méthode setProperty de l’objet IXMLDOMDocument2 peut échouer pour les sources de données secondaires. Pour utiliser la méthode setProperty, suivez cet exemple :

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

S’applique à