# XDocuments Collection

XDocuments XDocument

Contains an XDocument object for each Microsoft Office InfoPath 2003 form that is currently open. The XDocument object represents a form's underlying XML document and can be used to interact with the XML data that a form contains.

## Remarks

The XDocuments collection implements a number of properties and methods that can be used to access a form's associated XDocument object, or to create and open the forms themselves. The XDocuments collection is accessed through the XDocuments property of the Application object.

## Using the XDocuments collection

In the following example, the Open method of the XDocuments collection is used to open an existing form:

    Application.XDocuments.Open("C:\\MyForm.xml");

You can also create a new form based on an existing form using the New method:

    Application.XDocuments.New("C:\\MyForm.xml");

To access an XDocument object contained in the XDocuments collection, you can pass the positional index or the location path to the Item method:

    var objXDoc;

    objXDoc = Application.XDocuments(0);
    // or...
    objXDoc = Application.XDocuments("C:\\MyForm.xml");

For more information about using the XDocuments collection, see Accessing form data.

©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