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
<GuidAttribute("096CD6A8-0786-11D1-95FA-0080C78EE3BB")> _
Public Interface XDocument _
Inherits _XDocument2, _XDocumentEventSink2_Event
'Usage
Dim instance As XDocument
[GuidAttribute("096CD6A8-0786-11D1-95FA-0080C78EE3BB")]
public interface XDocument : _XDocument2,
_XDocumentEventSink2_Event
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.
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 |
---|---|
Accessed from Application. Provides Item for accessing the XDocument objects that it contains. |
|
Provides XDocument for accessing the source XML data during an XML DOM change. |
|
Provides XDocument for accessing the source XML data during a button click in the form area. |
|
Provides XDocument for accessing the source XML data during a switch view or form merge operation. |
|
Provides XDocument for accessing the source XML during the loading or submission of a form. |
|
Provides XDocument for accessing the source XML during the version upgrade operation. |
|
Provides XDocument for accessing the XDocument object associated with the window. |
Examples
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.