Share via


XDocuments2.NewFromSolutionWithData method

Creates a new Microsoft Office InfoPath form using the specified XML data and form template.

Namespace:  Microsoft.Office.Interop.InfoPath
Assembly:  Microsoft.Office.Interop.InfoPath (in Microsoft.Office.Interop.InfoPath.dll)

Syntax

'Declaration
Function NewFromSolutionWithData ( _
    varXMLData As Object, _
    varSolutionURI As Object, _
    dwBehavior As Integer _
) As XDocument
'Usage
Dim instance As XDocuments2
Dim varXMLData As Object
Dim varSolutionURI As Object
Dim dwBehavior As Integer
Dim returnValue As XDocument

returnValue = instance.NewFromSolutionWithData(varXMLData, _
    varSolutionURI, dwBehavior)
XDocument NewFromSolutionWithData(
    Object varXMLData,
    Object varSolutionURI,
    int dwBehavior
)

Parameters

  • varXMLData
    Type: System.Object

    Provides the XML data to be used as a template for the form. Can be a string that specifies the Uniform Resource Identifier (URI) of an XML document, or an XMLDOMNode that contains the XML to be used as the XML document (template).

  • varSolutionURI
    Type: System.Object

    Specifies the Uniform Resource Identifier (URI) of a form template file (an .xsf or .xsn file).

  • dwBehavior
    Type: System.Int32

    Reserved for future use. This value should be set to 1.

Return value

Type: Microsoft.Office.Interop.InfoPath.XDocument
An _XDocument object.

Remarks

The following related methods of the XDocuments collection are also available:

  • The New method enables creating a new instance of InfoPath by using a specified XML document. The XML document must correspond to an InfoPath form. A new form is opened in InfoPath, using the supplied XML document as initial data, and its associated form template as specified in the processing instructions in the header of the document.

  • The NewFromSolution method enables creating a new instance of InfoPath using a specified form template, and its associated XML form (the initial template data).

The NewFromSolutionWithData method supports a scenario that is not provided by the foregoing two methods: specifying both the XML document used as initial data and the form template. The XML document does not need to have been created by InfoPath. It can be supplied either as a URI or as an XMLDOMNode.

When you use the NewFromSolutionWithData method, the new form opens in InfoPath and is ready to be filled out.

Examples

Example 1:

// open a solution from an XML DOM
// Create a new DOM 
IXMLDOMDocument newDoc=thisXDocument.CreateDOM();
//Load DOM with some XML
string myXml="<person><firstName/><lastName/><address/><city/><country/></person>”;
newDoc.loadXML(myXml);
// Call NewSolutionWithData to open a new Form and load the XML
// the solution to edit the xml was published on SharePoint thisApplication.XDocuments.NewFromSolutionWithData(newDoc.documentElement,"https://localhost/Sample/forms/template.xsn",(int)XdDocumentVersionMode.xdFailOnVersionOlder);

Example 2:

// Open a solution from an xml file on disc
// the solution to edit the xml was published on SharePoint thisApplication.XDocuments.NewFromSolutionWithData(“c:\\myXmlFiles\\Sample.xml”,"https://localhost/Sample/forms/template.xsn",(int)XdDocumentVersionMode.xdFailOnVersionOlder);

See also

Reference

XDocuments2 interface

XDocuments2 members

Microsoft.Office.Interop.InfoPath namespace