_XDocument4.CreateDOM - Méthode
Crée une instance du modèle XML DOM (Document Object Model) en mémoire.
Espace de noms : Microsoft.Office.Interop.InfoPath
Assembly : Microsoft.Office.Interop.InfoPath (dans Microsoft.Office.Interop.InfoPath.dll)
Syntaxe
'Déclaration
Function CreateDOM As IXMLDOMDocument
'Utilisation
Dim instance As _XDocument4
Dim returnValue As IXMLDOMDocument
returnValue = instance.CreateDOM()
IXMLDOMDocument CreateDOM()
Valeur renvoyée
Type : Microsoft.Office.Interop.InfoPath.Xml.IXMLDOMDocument
Un IXMLDOMDocument accessible depuis une nouvelle instance du modèle DOM (Document Object Model) XML.
Implémentations
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");
Notes
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 :
IXMLDOMDocument3 myDocument = (IXMLDOMDocument3) thisXDocument.CreateDOM();
myDocument.setProperty("SelectionNameSpaces",namespaceString);
Exemples
// 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
((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);