XDocument Interface

Definition

Represents the underlying XML document of a form.

public interface class XDocument : Microsoft::Office::Interop::InfoPath::SemiTrust::_XDocument2
[System.Runtime.InteropServices.Guid("096cd6a8-0786-11d1-95fa-0080c78ee3bb")]
public interface XDocument : Microsoft.Office.Interop.InfoPath.SemiTrust._XDocument2
type XDocument = interface
    interface _XDocument2
    interface _XDocument
Public Interface XDocument
Implements _XDocument2
Attributes
Implements

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 (InfoPath 2003 Object Model).

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_XDocument2.

Using the members of the _XDocument2 interface provides compatibility with InfoPath 2003. To use new members that were added to the XDocument object model in Microsoft InfoPath 2010 such as the Permission property, you must cast the XDocument object to the _XDocument3 type. For more information, see How to: Use Object Model Members That Are Not Compatible with InfoPath 2003.

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.

XDocumentsCollection Accessed from Application. Provides Item[Object] for accessing the XDocument objects that it contains.
DataDOMEventObject Provides XDocument for accessing the source XML data during an XML DOM change.
DocActionEventObject Provides XDocument for accessing the source XML data during a button click in the form area.
DocEventObject Provides XDocument for accessing the source XML data during a switch view or form merge operation.
DocReturnEventObject Provides XDocument for accessing the source XML during the loading or submission of a form.
VersionUpgradeEventObject Provides XDocument for accessing the source XML during the version upgrade operation.
WindowObject Provides XDocument for accessing the XDocument object associated with the window.

Properties

DataAdapters

Gets a reference to the DataAdaptersCollection collection that is associated with a form.

(Inherited from _XDocument2)
DataObjects

Gets a reference to the DataObjectsCollection collection that is associated with a form.

(Inherited from _XDocument2)
DOM

Gets a reference to a form's underlying XML document in the form of an XML Document Object Model (DOM).

(Inherited from _XDocument2)
Errors

Gets a reference to the ErrorsCollection that is associated with a form.

(Inherited from _XDocument2)
Extension

Gets a reference to the global scripting object, which exposes the functions and global variables contained in a form's primary form code file.

(Inherited from _XDocument2)
IsDirty

Gets a value that indicates whether the data in a form has been modified since it was last saved.

(Inherited from _XDocument2)
IsDOMReadOnly

Gets a value that indicates whether the data in the underlying XML document of a form has been placed in a read-only state.

(Inherited from _XDocument2)
IsNew

Gets a value that indicates whether a newly created form has been saved.

(Inherited from _XDocument2)
IsReadOnly

Gets a value that indicates whether a form is in read-only mode.

(Inherited from _XDocument2)
IsRecovered

Gets a value that indicates whether a form was last saved by an AutoRecover save operation.

(Inherited from _XDocument2)
IsSigned

Gets a value that indicates whether a form has been digitally signed using digital signatures.

(Inherited from _XDocument2)
Language

Gets or sets a form's default language code.

(Inherited from _XDocument2)
QueryAdapter

Gets a reference to the data adapter object that is associated with a form.

(Inherited from _XDocument2)
Role

Gets or sets the user's current role.

(Inherited from _XDocument2)
SignedDataBlocks

Gets a reference to the SignedDataBlocksCollection collection that is associated with an XDocument object.

(Inherited from _XDocument2)
Solution

Gets a reference to the SolutionObject object that is associated with a form.

(Inherited from _XDocument2)
UI

Returns a reference to UIObject object.

(Inherited from _XDocument2)
URI

Gets the Uniform Resource Identifier (URI) of a form.

(Inherited from _XDocument2)
Util

Gets a reference to UtilObject object.

(Inherited from _XDocument2)
View

Gets a reference to the ViewObject associated with a form.

(Inherited from _XDocument2)
ViewInfos

Gets a reference to the ViewInfosCollection collection associated with a form.

(Inherited from _XDocument2)

Methods

CreateDOM()

Creates a new instance of the XML Document Object Model (DOM) in memory.

(Inherited from _XDocument2)
GetDataVariable(Int32)

Gets the value of the specified variable, which is a predefined variable stored as a processing instruction attribute in the form's underlying XML document.

(Inherited from _XDocument2)
GetDOM(String)

Gets a reference to the XML Document Object Model (DOM) of the specified DataSourceObject object associated with the XDocument object.

(Inherited from _XDocument2)
GetNamedNodeProperty(Object, String, String)

Gets the value of a named property for the specified XML node, which must be a nonattribute node in the main data source.

(Inherited from _XDocument2)
ImportDOM(IXMLDOMDocument)

Imports the specified XML data into the current form.

(Inherited from _XDocument2)
ImportFile(String)

Imports the specified form into the current form.

(Inherited from _XDocument2)
PrintOut()

Prints the form content as it is rendered in the window corresponding to the form's active view.

(Inherited from _XDocument2)
Query()

Retrieves data from a form's associated data adapter object and stores the data in the form's underlying XML Document Object Model (DOM).

(Inherited from _XDocument2)
Save()

Saves the form to the Uniform Resource Locator (URL) that it is currently associated with.

(Inherited from _XDocument2)
SaveAs(String)

Saves the form to the specified Uniform Resource Locator (URL).

(Inherited from _XDocument2)
SetDataVariable(Int32, String)

Sets the value of a predefined variable stored as a processing instruction attribute in the form's underlying XML document.

(Inherited from _XDocument2)
SetDirty(Boolean)

Sets the IsDirty property for the XDocument object, which indicates whether the data in a form has been modified since it was last saved.

(Inherited from _XDocument2)
SetNamedNodeProperty(IXMLDOMNode, String, String)

Sets the value of a named property for the supplied XML node, which must be a nonattribute node in the main data source.

(Inherited from _XDocument2)
Submit()

Executes the predefined submit operation in a form.

(Inherited from _XDocument2)

Applies to