XML - Create session
Declaration
<AMXML ACTIVITY="create_node" XPATH="text" NEWNODE="text" NEWVALUE="text" DEFAULTNSPREFIX="text" DEFAULTNAMESPACE="text" INSERTAT="text (options)" SPECIFIEDNODE="text" SPECIFIEDNODENOTEXIST="text (options)" SESSION="text"><ATTRIBUTE NAME="text" VALUE="text" /><NAMESPACE PREFIX="text" URI="text" /></AMXML>
Description
Creates a new session based on the XML file or text specified. During an XML session, modifications are not performed on the original XML file bound by that session. Rather, as a safety measure, a copy of the file is saved to memory. Any modifications by subsequent XML steps are performed on the copy of the XML data saved to memory. Multiple XML documents can be saved to memory simultaneously allowing several sessions to exist within a single task. Use the Output XML action to output the final XML data to the original XML file or optionally, a new file. Use the End XML Session action to end an active session.
Practical usage
Used to create an in-memory XML document to be used in subsequent XML actions.
Parameters
Session
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Create XML session from | Text (options) | Yes | Existing File |
|
Specifies
where the XML data should derive from in order to start the new
session. The XML data will be saved into memory. Different parameters
become active depending on which option is selected. The available
options are:
|
File | Text | Yes, if session derives from new or existing file | (Empty) | FILE="c:\foldername\file.XML" | The path and file name of the new or existing XML file. This parameter is active only if the Create XML session from parameter is set to Existing file or New file. |
Overwrite if file exists | Yes/No | Yes, if session derives from new file | No | OVERWRITEFILE="YES" | If selected, specifies that if an XML file with the same name already exists at the specified location, it will be overwritten with the new file. If disabled (default), the step fails if the file already exists. This parameter is active only if the Create XML session from parameter is set to New file. |
Root node name | Text | Yes, if session derives from new file | (Empty) | ROOTNODENAME="Fortra" | The root node name for new XML file. This parameter is active only if the Create XML session from parameter is set to New file. |
Root node value (optional) | Text | No | (Empty) | NEWVALUE="Value" | The root node value for the new XML file. This parameter is active only if the Create XML session from parameter is set to New file. |
Default namespace prefix (optional) | Text | No | (Empty) | DEFAULTNSPREFIX="edi" | The prefix of the default namespace for the new XML file. A namespace prefix is a text string assigned as an element name prefix to a namespace. When an element name is preceded by the prefix and a colon, then that element is in that assigned namespace. This parameter is active only if the Create XML session from parameter is set to New file. |
Default namespace URI (optional) | Text | No | (Empty) |
DEFAULTNAMESPACE="http://net.com/schema" |
The default namespace URI for the new XML file. An XML namespace is a collection of element type and attribute names that are uniquely identified by the name of the unique XML namespace of which they are a part. This parameter is active only if the Create XML session from parameter is set to New file. |
Text | Text | Yes, if session derives from text | (Empty) | XMLTEXT="theText" | The text that the XML data should originate from. This parameter is active only if the Start XML session from parameter is set to Text. |
Session | Text | No | (Empty) | SESSIONNAME="FirstXMLSession" | The session name to identify the in-memory XML document to use in subsequent XML steps. This allows several in memory XML documents to be active simultaneously. Use the Output XML action to output the final XML data to the original XML file or optionally, a new file. Use the End XML Session action to end an active session. |
Namespace
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Namespace Prefix | Text | No | (Empty) | PREFIX="PrefixName" | The prefix associated to the added namespace. Use this parameter to insert namespace prefix and URI values into the new node. To enter a new row of values select Click here to add new row. To delete an existing row, click the red "X." This parameter supports insertion of multiple namespace prefixes and URIs. |
Namespace URI | Text | No | (Empty) | URI="URIName" | The URI associated to the added namespace. Use this parameter to insert namespace prefix and URI values into the new node. To enter a new row of values select Click here to add new row. To delete an existing row, click the red "X." This parameter supports insertion of multiple namespace prefixes and URIs |
Example
- Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
- To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.
Example 1
This sample task starts an XML session that originates from an existing XML file.
<AMXML FILE="C:\Tutorials\XML Data\book.xml" SESSION="XmlSession1" />
Example 2
This sample task starts an XML session that originates from a newly created XML file.
<AMXML XMLDOCUMENTFROM="newfile" FILE="C:\Tutorials\XML Data\NewFile.xml" OVERWRITEFILE="YES" ROOTNODENAME="Fortra" NEWVALUE="Automate" DEFAULTNSPREFIX="edi" DEFAULTNAMESPACE="http://netauto.com/schema" SESSION="XmlSession1"><ATTRIBUTE NAME="License" VALUE="Standard" /><ATTRIBUTE NAME="Version" VALUE="11" /></AMXML>
Example 3
This sample task starts an XML session that originates from the specified text.
<AMXML XMLDOCUMENTFROM="text" XMLTEXT="theText; No Code No Limit!" SESSION="XmlSession1" />