File: inconAccessingFormData.htm

package info (click to toggle)
office2003-schemas 1.0%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, sid, trixie
  • size: 42,304 kB
  • sloc: javascript: 2,429; makefile: 29
file content (15 lines) | stat: -rw-r--r-- 13,664 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<html dir="ltr"><head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="assetid" CONTENT="HV01039907"><META NAME="lcid" CONTENT="1033"><title>Accessing form data</title><link rel="stylesheet" type="text/css" href="office10.css"><script type="text/javascript" language="Javascript" src="ExpCollapse.js"></script><script type="text/javascript" language="JavaScript" src="inline.js"></script></head><body><p id="ExpandAllLine" class="ExpFav"><a href="#" onclick="ExpandAll()" onkeypress="ExpandAll()" class="DropDown"><img id="picHeader" border="0" src="expandtri.gif" alt="Show All"><span id="ExpandAll">Show All</span></a></p><h1>Accessing form data</h1><div class="ofvbanav"><span class="ofvbanavreuse" id="seealso" onclick="toggleList()" onkeypress="toggleList()"></span><span class="ofvbanavreuse" id="specifics" onclick="toggleList()" onkeypress="toggleList()"></span></div><p>When you want to extend the functionality of a Microsoft Office InfoPath 2003 form, it is often necessary to programmatically access information about the form's underlying XML document, access the data that the XML document contains, or perform some action on the XML document. The InfoPath object model supports access and manipulation of a form's underlying XML document through the use of the <b class="bterm"><a href="xdobjXDocument.htm" id="HV01021254" lcid=" ">XDocument</a></b> object in association with the <b class="bterm"><a href="xdcolXDocuments.htm" id="HV01021190" lcid=" ">XDocuments</a></b> collection.</p><p>The <b class="bterm">XDocument</b> object is one of the most useful objects within the InfoPath object model because it provides a variety of properties, methods, and events that not only interact with a form's underlying XML document, but also perform many of the actions that are within the InfoPath user interface.</p><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Overview of the XDocuments collection</a></p><div id="ExpCol" class="collapsed" border="0"><p>The  <b class="bterm">XDocuments</b> collection provides the following methods and properties that form developers can use to manage the <b class="bterm">XDocument</b> objects that the collection contains.</p><table><tr><th>Name</th><th>Description</th></tr><tr><td><b class="bterm"><a href="xdmthClose_1.htm" id="HV01021380" lcid=" ">Close</a></b> method</td><td>Closes the specified form</td></tr><tr><td><b class="bterm"><a href="xdmthNew_2.htm" id="HV01021394" lcid=" ">New</a></b> method</td><td>Creates a new form based on an existing form</td></tr><tr><td><b class="bterm"><a href="xdmthNewFromSolution_2.htm" id="HV01021395" lcid=" ">NewFromSolution</a></b> method</td><td>Creates a new form based on an existing <a href="#" class="glossary" onclick="AppendPopup(this,'xdformtemplate')" onkeypress="AppendPopup(this,'xdformtemplate')">form template</a></td></tr><tr><td><b class="bterm"><a href="xdmthNewFromSolutionWithData_HV01103984.htm" id="HV01103984" lcid=" ">NewFromSolutionWithData</a></b> method</td><td>Creates a new Microsoft Office InfoPath 2003 form using the specified XML data and form template.</td></tr><tr><td><b class="bterm"><a href="xdmthOpen_2.htm" id="HV01021396" lcid=" ">Open</a></b> method</td><td>Opens the specified form</td></tr><tr><td><b class="bterm"><a href="xdproCount_1.htm" id="HV01021271" lcid=" ">Count</a></b> property</td><td>Returns a count of the number of <b class="bterm">XDocument</b> objects contained in the collection</td></tr><tr><td><b class="bterm"><a href="xdproItem_2.htm" id="HV01021295" lcid=" ">Item</a></b> property</td><td>Returns a reference to the specified <b class="bterm">XDocument</b> object</td></tr></table></div><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Overview of the XDocument object</a></p><div id="ExpCol" class="collapsed" border="0"><p>The  <b class="bterm">XDocument</b> object provides the following methods and properties that form developers can use to interact with and perform actions on a  form's underlying XML document.</p><table><tr><th>Name</th><th>Description</th></tr><tr><td><b class="bterm"><a href="xdmthGetDataVariable.htm" id="HV01021390" lcid=" ">GetDataVariable</a></b> method </td><td>Returns the string value of a specified data variable</td></tr><tr><td><b class="bterm"><a href="xdmthGetDOM.htm" id="HV01021387" lcid=" ">GetDOM</a></b> method</td><td>Returns a reference to the XML <a href="#" class="glossary" onclick="AppendPopup(this,'ofdocumentobjectmodeldom')" onkeypress="AppendPopup(this,'ofdocumentobjectmodeldom')">Document Object Model (DOM)</a> associated with the specified <b class="bterm"><a href="xdobjDataObject.htm" id="HV01024616" lcid=" ">DataObject</a></b> object</td></tr><tr><td><b class="bterm"><a href="xdmthImportFile.htm" id="HV01021393" lcid=" ">ImportFile</a></b> method</td><td>Imports (or merges) the specified form with the currently open form</td></tr><tr><td><b class="bterm"><a href="xdmthPrintOut.htm" id="HV01021397" lcid=" ">PrintOut</a></b> method</td><td>Prints the current view of a form</td></tr><tr><td><b class="bterm"><a href="xdmthQuery_2.htm" id="HV01021399" lcid=" ">Query</a></b> method</td><td>Retrieves data from a form's associated <a href="#" class="glossary" onclick="AppendPopup(this,'xddataadapter')" onkeypress="AppendPopup(this,'xddataadapter')">data adapter</a></td></tr><tr><td><b class="bterm"><a href="xdmthSave.htm" id="HV01021406" lcid=" ">Save</a></b> method</td><td>Saves the currently open form</td></tr><tr><td><b class="bterm"><a href="xdmthSaveAs.htm" id="HV01021407" lcid=" ">SaveAs</a></b> method</td><td>Saves the currently open form with the specified name</td></tr><tr><td><b class="bterm"><a href="xdmthSetDataVariable.htm" id="HV01021410" lcid=" ">SetDataVariable</a></b> method</td><td>Sets the value of a specified data variable</td></tr><tr><td><b class="bterm"><a href="xdmthSubmit.htm" id="HV01021418" lcid=" ">Submit</a></b> method</td><td>Submits a form according to the submit operation established in <a href="#" class="glossary" onclick="AppendPopup(this,'xddesignmode')" onkeypress="AppendPopup(this,'xddesignmode')">design mode</a></td></tr><tr><td><b class="bterm"><a href="xdproDataObjects.htm" id="HV01021279" lcid=" ">DataObjects</a></b> property</td><td>Returns a reference to the <b class="bterm"><a href="xdcolDataObjects.htm" id="HV01021185" lcid=" ">DataObjects</a></b> collection</td></tr><tr><td><b class="bterm"><a href="xdproDOM_2.htm" id="HV01032776" lcid=" ">DOM</a></b> property</td><td>Returns a reference to the XML DOM that is populated with the source XML data of a form</td></tr><tr><td><b class="bterm"><a href="xdproErrors.htm" id="HV01021283" lcid=" ">Errors</a></b> property</td><td>Returns a reference to the <b class="bterm"><a href="xdcolErrors.htm" id="HV01021186" lcid=" ">Errors</a></b> collection</td></tr><tr><td><b class="bterm"><a href="xdproExtension.htm" id="HV01021284" lcid=" ">Extension</a></b> property</td><td>Returns a reference to an object representing all of the functions and variables contained in a form's scripting file</td></tr><tr><td><b class="bterm"><a href="xdproIsDirty.htm" id="HV01021288" lcid=" ">IsDirty</a></b> property</td><td>Returns a Boolean value indicating whether the data in the form has been changed</td></tr><tr><td><b class="bterm"><a href="xdproIsDOMReadOnly.htm" id="HV01024632" lcid=" ">IsDOMReadOnly</a></b> property</td><td>Returns a Boolean value indicating whether the XML DOM is set as read-only</td></tr><tr><td><b class="bterm"><a href="xdproIsNew.htm" id="HV01021289" lcid=" ">IsNew</a></b> property</td><td>Returns a Boolean value indicating whether the form was saved after it was created</td></tr><tr><td><b class="bterm"><a href="xdproIsReadOnly.htm" id="HV01021290" lcid=" ">IsReadOnly</a></b> property</td><td>Returns a Boolean value indicating whether the form is in read-only mode</td></tr><tr><td><b class="bterm"><a href="xdproIsSigned.htm" id="HV01021292" lcid=" ">IsSigned</a></b> property</td><td>Returns a Boolean value indicating whether the form is digitally signed</td></tr><tr><td><b class="bterm"><a href="xdproLanguage.htm" id="HV01021305" lcid=" ">Language</a></b> property</td><td>Specifies or returns the string value of the language used for the form</td></tr><tr><td><b class="bterm"><a href="xdproQueryAdapter_1.htm" id="HV01021319" lcid=" ">QueryAdapter</a></b> property</td><td>Returns a reference to the data adapter object</td></tr><tr><td><b class="bterm"><a href="xdproSolution.htm" id="HV01021333" lcid=" ">Solution</a></b> property</td><td>Returns a reference to the <b class="bterm"><a href="xdobjSolution.htm" id="HV01021245" lcid=" ">Solution</a></b> object</td></tr><tr><td><b class="bterm"><a href="xdproUI.htm" id="HV01021347" lcid=" ">UI</a></b> property</td><td>Returns a reference to the <b class="bterm"><a href="xdobjUI.htm" id="HV01021247" lcid=" ">UI</a></b> object</td></tr><tr><td><b class="bterm"><a href="xdproURI_1.htm" id="HV01021348" lcid=" ">URI</a></b> property</td><td>Returns a string value containing the <a href="#" class="glossary" onclick="AppendPopup(this,'ofuniformresourceidentifieruri')" onkeypress="AppendPopup(this,'ofuniformresourceidentifieruri')">Uniform Resource Identifier (URI)</a> of the form</td></tr><tr><td><b class="bterm"><a href="xdproView.htm" id="HV01021352" lcid=" ">View</a></b> property</td><td>Returns a reference to the <b class="bterm"><a href="xdobjView.htm" id="HV01021249" lcid=" ">View</a></b> object</td></tr><tr><td><b class="bterm"><a href="xdproViewInfos.htm" id="HV01021353" lcid=" ">ViewInfos</a></b> property</td><td>Returns a reference to the <b class="bterm"><a href="xdcolViewInfos.htm" id="HV01021188" lcid=" ">ViewInfos</a></b> collection</td></tr></table><p><b>Note</b>  The <b class="bterm">XDocument</b> object also implements five events that are not shown in the preceding table. For information about these events, see the <b class="bterm">XDocument</b> object language reference topic in the InfoPath Developer's Reference.</p></div><p><a href="#" class="DropDown" onclick="Outline2()" onkeypress="Outline2()"><img border="0" src="blueup.gif" alt="Show">Using the XDocuments collection and the XDocument object</a></p><div id="ExpCol" class="collapsed" border="0"><p>The <b class="bterm">XDocuments</b> collection is accessed through the <b class="bterm"><a href="xdproXDocuments.htm" id="HV01021365" lcid=" ">XDocuments</a></b> property of the <b class="bterm"><a href="xdobjApplication.htm" id="HV01021256" lcid=" ">Application</a></b> object. When using the <b class="bterm">XDocuments</b> collection to access a form's underlying XML document, you pass a long integer or a string to the <b class="bterm">Item</b> method to return a reference to an <b class="bterm">XDocument</b> object. For example, if you have a form named MyForm, both of the following lines of code will return a reference to the same <b class="bterm">XDocument</b> object if it is the first <b class="bterm">XDocument</b> object in the <b class="bterm">XDocuments</b> collection:</p><pre><code>var objXDocs;

objXDocs = Application.XDocuments(0);
// is the same as using...
objXDocs = Application.XDocuments("MyForm");</code></pre><p>However, it is much simpler to access a form's underlying XML document by using the <b class="bterm">XDocument</b> object directly, without using the <b class="bterm">XDocuments</b> collection. This is possible because the <b class="bterm">XDocument</b> object is embedded directly in the InfoPath script engine. For example, the following code performs the same operation as the previous example:</p><pre><code>var objXDoc;
objXDoc = XDocument;</code></pre><p><b>Note</b>  When you use the <b class="bterm">XDocument</b> object to access a form's underlying XML document, you are accessing the XML document that is associated with the currently open form.</p><p>A key property of the <b class="bterm">XDocument</b> object is the <b class="bterm">DOM</b> property. This property returns a reference to the XML DOM that is populated with the source XML data of a form. When using the <b class="bterm">DOM</b> property, you can use any of the properties and methods that are supported by the XML DOM. For example, the following code uses the <b class="bterm">xml</b> property of the XML DOM to return all of the contents of a form's underlying XML document:</p><pre><code>var strXML;
strXML = XDocument.DOM.xml;</code></pre><p><b>Note</b>  To learn more about the XML DOM and all of the properties and methods that it supports, see the MSXML 5.0 SDK documentation in the <a href="#" class="glossary" onclick="AppendPopup(this,'xdmicrosoftscripteditormse')" onkeypress="AppendPopup(this,'xdmicrosoftscripteditormse')">Microsoft Script Editor (MSE)</a> Help system.</p></div><script type="text/javascript" language="JScript" src="ofvbanl.js"></script><span id="ofVBAISpan" class="ofvbaispan"><iframe id="ofVBAIFrame" frameborder="0" marginheight="0" marginwidth="4" scrolling="auto" width="100%" src="../links/inconAccessingFormData_l.htm"></iframe></span><center><a href="XMLSchemaCopyright_HV01147162.htm">&copy;2003-2004 Microsoft Corporation. All rights reserved.</a>  

Permission to copy, display and distribute this document is available at: <a 

href="http://r.office.microsoft.com/r/rlidAWSContentRedir?AssetID=XT010988631033&amp;CTT=11&amp;Origin=HV011232471033" 

target="_new">http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp</a></center></body></html>