Share via


XmlForm.MergeForm Method (XPathNavigator) (Microsoft.Office.InfoPath)

Merges the current form with the target form specified in the node returned by the XPathNavigator passed to the method.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

Syntax

'Declaration
Public MustOverride Sub MergeForm ( _
    target As XPathNavigator _
)
'Usage
Dim instance As XmlForm
Dim target As XPathNavigator

instance.MergeForm(target)
public abstract void MergeForm (
    XPathNavigator target
)

Parameters

  • target
    An XPathNavigator that provides the XML data to merge into the current form.

Exceptions

Exception type Condition

InvalidOperationException

The MergeForm method was called from the Loading event.

ArgumentNullException

The parameter passed to this method is null.

ArgumentException

The parameter passed to this method isnot valid. For example, it is of the wrong type or format.

Remarks

The MergeForm method is equivalent to using the Merge Forms command on the File menu. The XML data provided by XPathNavigator passed as the target parameter must be a valid XML for merging into the current form. If the XML data provided isn't wrapped as an InfoPath form, InfoPath will wrap the data.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed only from code running in forms opened in Microsoft Office InfoPath 2007.

Example

In the following example, a System.Xml.XmlDocument object is used to load a form from the specified URL, and then a System.Xml.XPath.XPathNavigator object is positioned at the root of the form to merge. Finally, the XPathNavigator is passed to the MergeForm(System.Xml.XPath.XPathNavigator) method to merge the form into the current form.

string pathToFile = @"C:\FormToMerge\Form1.xml";
XmlDocument FormXML = new XmlDocument();

// The form tempate must be Full Trust for the 
// XmlDocument.Load method to work.
FormXML.Load(pathToFile);

XPathNavigator nav = FormXML.CreateNavigator();

// Merge the root node (the entire document) into the current form.
this.MergeForm(nav);
Dim pathToFile As String = "C:\FormToMerge\Form1.xml"
Dim FormXML As New XmlDocument

' The form tempate must be Full Trust for the 
' XmlDocument.Load method to work.
FormXML.Load(pathToFile)

Dim nav As XPathNavigator = FormXML.CreateNavigator()

' Merge the root node (the entire document) into the current form.
Me.MergeForm(nav)

See Also

Reference

XmlForm Class
XmlForm Members
Microsoft.Office.InfoPath Namespace