XDocuments Collection

InfoPath Developer Reference

Contains an XDocument object for each Microsoft Office InfoPath 2007 form that is currently open.

Version Information
 Version Added:  InfoPath 2003

Remarks

The XDocument object represents a form's underlying XML document and can be used to interact with the XML data that a form contains.

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.

For more information about using the XDocuments collection, see Working with data in a form's underlying XML document.

Example

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

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

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

JScript
  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:

JScript
  var objXDoc;

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

See Also