Show All

# XMLNodes Collection

XMLNodes

Contains a collection of XML Document Object Model (DOM) nodes. The XMLNodes collection is a general-purpose collection that is used by a number of Microsoft Office InfoPath 2003 methods.

## Remarks

The XMLNodes collection provides properties that can be used to access a collection of XML DOM nodes, and it is returned by both the GetSelectedNodes and GetContextNodes methods of the View object.

After you have set a reference to one of the XML DOM node objects that the XMLNodes collection contains, you can use any of the properties and methods that the XML DOM provides for interacting with an XML node object.

Note To learn more about the XML DOM and all of the properties and methods that it supports, see the MSXML 5.0 SDK documentation in the Microsoft Script Editor (MSE) Help system.

## Using the XMLNodes collection

In the following example, a reference is set to a collection of XML DOM nodes returned by the GetSelectedNodes method of the View object. Then the code displays the name and source XML of the first node found in the collection using a message box:

    var objXMLNodes;

    objXMLNodes = XDocument.View.GetSelectedNodes();

    if (objXMLNodes.Count > 0)
    {
       XDocument.UI.Alert(objXMLNodes(0).nodeName + "\n\n" + objXMLNodes(0).text);
    }

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp