XDocuments2.NewFromSolutionWithData(Object, Object, Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a new Microsoft InfoPath form using the specified XML data and form template.
public:
Microsoft::Office::Interop::InfoPath::SemiTrust::XDocument ^ NewFromSolutionWithData(System::Object ^ varXMLData, System::Object ^ varSolutionURI, int dwBehavior);
public Microsoft.Office.Interop.InfoPath.SemiTrust.XDocument NewFromSolutionWithData (object varXMLData, object varSolutionURI, int dwBehavior);
abstract member NewFromSolutionWithData : obj * obj * int -> Microsoft.Office.Interop.InfoPath.SemiTrust.XDocument
Public Function NewFromSolutionWithData (varXMLData As Object, varSolutionURI As Object, dwBehavior As Integer) As XDocument
Parameters
- varXMLData
- 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
- Object
Specifies the Uniform Resource Identifier (URI) of a form template file (an .xsf or .xsn file).
- dwBehavior
- Int32
Reserved for future use. This value should be set to 1.
Returns
An _XDocument object.
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.<span class="label">NewFromSolutionWithData</span>(newDoc.documentElement,"http://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.<span class="label">NewFromSolutionWithData</span>(“c:\\myXmlFiles\\Sample.xml”,"http://localhost/Sample/forms/template.xsn",(int)XdDocumentVersionMode.xdFailOnVersionOlder);
Remarks
The following related methods of the XDocuments collection are also available:
- The New(Object, Int32) 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(Object) 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.
Important: 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.