XDocument Object
XDocuments XDocument |
Represents the underlying XML document of a Microsoft Office InfoPath 2003 form.
Remarks
The XDocument object is a key object in the InfoPath object model that provides properties, methods, and events that can be used to programmatically interact with and manipulate the source XML data of a form.
Note The XDocument object is embedded in the InfoPath script engine. While the XDocument object can be accessed using the XDocuments collection, in most cases you will access it directly, without going through the collection.
Using the XDocument object
The source XML data of a form takes the form of an XML Document Object Model (DOM), which is accessed through the DOM property of the XDocument object. The XDocument object also provides a number of properties that can be used to get information about the form and its underlying XML document. For example, the following code checks to see whether data in the form has been changed by using the IsDirty property:
if (XDocument.IsDirty)
XDocument.UI.Alert("Form has been changed.");
else
XDocument.UI.Alert("Form has not been changed.");
In addition to information about the form and its underlying XML document, the XDocument object provides a number of methods that can be used on the form, such as printing, saving, and submitting. It also provides a number of events that can be used to respond to various actions that occur at the form level, such as loading of a form, switching views, or a merge operation.
Accessing the XDocument object
The XDocument object can be accessed in a variety places within the InfoPath object model. The following table summarizes the locations where the XDocument object is available.
Name | Description |
---|---|
XDocuments collection | Accessed from the Application object. Provides the Item property for accessing the the XDocument objects that it contains. |
DataDOMEvent object | Provides an XDocument property for accessing the source XML data during an XML DOM change. |
DocActionEvent object | Provides an XDocument property for accessing the source XML data during a button click in the form area. |
DocEvent object | Provides an XDocument property for accessing the source XML data during a switch view or form merge operation. |
DocReturnEvent object | Provides an XDocument property for accessing the source XML during the loading or submission of a form. |
VersionUpgradeEvent object | Provides an XDocument property for accessing the source XML during during the version upgrade operation. |
Window object | Provides an XDocument property for accessing the XDocument object associated with the window. |
Note For more information about using the XDocument object , see Accessing form data.
Properties | DataAdapters Property | DataObjects Property | DOM Property (XDocument Object) | Errors Property | Extension Property | IsDirty Property | IsDOMReadOnly Property | IsNew Property | IsReadOnly Property | IsRecovered Property | IsSigned Property | Language Property | QueryAdapter Property (XDocument Object) | Role Property | SignedDataBlocks Property | Solution Property | UI Property | URI Property (XDocument Object) | Util Property | View Property | ViewInfos Property
Methods | CreateDOM Method | GetDataVariable Method | GetDOM Method | GetNamedNodeProperty Method | ImportDOM Method | ImportFile Method | PrintOut Method | Query Method (XDocument Object) | Save Method | SaveAs Method | SetDataVariable Method | SetDirty Method | SetNamedNodeProperty Method | Submit Method (XDocument Object)
Events | OnAfterImport Event | OnContextChange Event | OnLoad Event | OnMergeRequest Event | OnSaveRequest Event | OnSign Event | OnSubmitRequest Event | OnSwitchView Event | OnVersionUpgrade Event