Поделиться через


_XDocument4.CreateDOM Метод

Определение

Создает новый экземпляр модели объектов XML-документов (DOM) в памяти.

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

Возвращаемое значение

IXMLDOMDocument, доступ к которому можно получить из нового экземпляра модели объектов XML-документов (DOM).

Реализации

Примеры

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

Комментарии

Использование метода CreateDOM для создания экземпляра модели XML DOM эквивалентно использованию следующего метода создания объекта Microsoft XML Core Services (MSXML) 5.0 DOMDocument:

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

Примечание. При автоматизации InfoPath метод setProperty объекта IXMLDOMDocument2 может завершиться ошибкой для вторичных источников данных. Чтобы использовать метод setProperty, придерживайтесь следующего примера:

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

Применяется к