# DocEvent Object

DocEvent

An event object that is used during a Microsoft Office InfoPath 2003 merge or view switching event. The DocEvent object provides the XDocument property that can be used within a merge or view switching event to programmatically interact with the data in a form's underlying XML document.

## Remarks

The DocEvent object is passed as a parameter to the OnSwitchView and OnAfterChange events of an InfoPath form. The XDocument property that it provides is available only during these events.

## Using the DocEvent object

In the following example, the XDocument property of the DocEvent object is used to display the source XML of a form's underlying XML document using the DOM property of the XDocument object:

    function XDocument::OnSwitchView(eventObj)
    {
       XDocument.UI.Alert("The source XML: " + eventObj.XDocument.DOM.xml);
    }

For more information about using the DocEvent object, see Responding to form events.

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp