Community articleEncloseInstance function
Added by IBM contributorIBM on July 26, 2013
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars


This function modifies one instance in the data model, either updating information or appending information. Note that the form must have an existing data model.
Call this function on the root node of the form or an XML instance node.
Note: Use caution when calling this function. It can be used to overwrite signed instance data.


   Sub EncloseInstance(
      theInstanceID As String, 
      theFile As String, 
      theFlags As Long, 
      theScheme As String, 
      theRootReference As String, 
      theNSNode As IFormNodeP, 
      replaceNode As Boolean)


Table 1. Function parameters
theInstanceIDStringThe ID of the instance node to create or replace. This is defined by the id attribute of that node, and is case sensitive.
To replace the root node of the form, set this parameter to null.
theFileStringThe path to the file on the local drive that contains the XML instance. Note that this file must be UTF-8.
theFlagsLongReserved. Must be 0.
theSchemeStringReserved. Must be null.
theRootReferenceStringA reference to the node you want to replace or append children to. This reference is relative to the instance node.
Use null to default to the instance node.
theNSNodeIFormNodePA node that inherits the namespaces used in the reference. This node defines the namespaces for the function. Use null if the node that this function is operating on has inherited the necessary namespaces.
replaceNodeBooleanIf True, the node specified by theRootReference is replaced with data. If False, the data is appended as the last child of the theRootReference node.


Nothing if call is successful or throws an exception if an error occurs.


The following example shows a function that takes the root node of a form and updates the XML instance called "data".
   Sub UpdateDataInstance(Form)
      Form.EncloseInstance "Test", "c:\DataInstance.txt", 0, vbNullString, _
         vbNullString, Nothing, False
   End Sub

Parent topic:
FormNodeP functions