XDocument Interface
Represents the underlying XML document of a Microsoft Office InfoPath form.
Namespace: Microsoft.Office.Interop.InfoPath
Assembly: Microsoft.Office.Interop.InfoPath (in microsoft.office.interop.infopath.dll)
Syntax
'Declaration
'Usage
Remarks
This type is a wrapper for a coclass that is required by managed code for COM interoperability. Use this type to access the members of the COM interface implemented by this coclass. For information about the COM interface, including a link to descriptions of its members, see _XDocument3.
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.
While the XDocument object can be accessed using the XDocumentsCollection collection, in most cases you will access it from the thisXDocument
variable that is instantiated in the _Startup method of a managed-code project without going through the collection.
The source XML data of a form takes the form of an XML Document Object Model (DOM), which is accessed through the DOM property. The XDocument object also provides a number of properties that can be used to get information about the form and its underlying XML document. It also provides a number of methods that can be used on the form, such as printing, saving, and submitting. The XDocument object 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.
Example
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 (thisXDocument.IsDirty)
{
thisXDocument.UI.Alert("Form has been changed.");
}
else
{
thisXDocument.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.
For another sample that demonstrates working with the XDocument object, see
How to: Access Application Data Using the InfoPath 2003 Object Model.
See Also
Reference
XDocument Members
Microsoft.Office.Interop.InfoPath Namespace