XML - Create Node
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 node in an existing XML file. Optionally assigns one or more attribute name value pairs into the new node.
Practical Usage
Mainly used to create a new node or modify an existing node in an XML document tree.
Session Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Session |
Text |
Yes |
XMLSession1 |
SESSIONNAME="myXMLSession" |
The name of an existing session in which to associate this activity with. As a safety measure, when a session is created, the XML file bound by that session is saved in memory and the original file is locked. Any modifications by subsequent XML steps are performed on a copy of the XML data saved to memory. Linking several activities to a single session eliminates redundancy. Additionally, a single task supports simultaneous execution of multiple sessions, improving overall efficiency. Use the XML - Output file or XML - Save activity to output the in-memory representation of the XML session to a file or variable. To end the session, use the XML - End session activity. |
Node Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
XPath expression |
Text |
Yes |
(Empty) |
XPATH="/bookstore/book" |
The XPath expression to the XML node in which to create. |
Name |
Text |
Yes |
(Empty) |
NEWNODE="NodeName" |
The name of the new node to be created. |
Value |
Text |
No |
(Empty) |
VALUE="theValue" |
The value of the new node to be created. |
If node already exists |
Text (options) |
No |
Ignore |
|
Specifies what action to perform if a node with same name as the one being inserted at the current location already exists. The available options are:
|
Insert as first child node |
Yes/No |
No |
No |
INSERTASFIRSTCHILD="YES" |
If set to YES, allows insertion of the new node as a first child of the parent node found using Xpath Expression. The default value is set to NO. |
Advanced Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Default namespace prefix (optional) |
Text |
No |
(Empty) |
DEFAULTNSPREFIX="thePrefix" |
The prefix associated to the default namespace. |
Default namespace URI (optional) |
Text |
No |
(Empty) |
DEFAULTNAMESPACE="default" |
The URI of the default namespace. |
Insert node at |
Text (options) |
No |
Beginning of child nodes |
|
Specifies where to insert the node onto the child node(s). The available options are:
|
Specified child node name |
Text |
No |
(Empty) |
SPECIFIEDNODE="nodeName" |
The name of the child node in which to insert the node before or after. This parameter is active only if the Insert node at parameter is set to After specified child node or Before specified child node. |
If specifies child node does not exist |
Text (options) |
No |
Skip |
SPECIFIEDNODENOTEXIST= "fail" |
Specifies what action to perform if the specified child node does not exist. This option is active only if the Insert node at parameter is set to After specified child node or Before specified child node. The available options are:
|
Attribute Name |
Text |
No |
(Empty) |
Name="AttribName" |
The name portion of the attribute name value pair to insert. Use this parameter to insert attributes 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 attribute name value pairs. |
Attribute Value |
Text |
No |
(Empty) |
Value="AttribValue" |
The value portion of the attribute name value pair to insert. Use this parameter to insert attributes 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 attribute name value pairs. |
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 |
Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.
Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)
On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)
Example
The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.
Description: This sample step creates a node with name "Euro" and value "10" at XPath location "/bookstore/book/price". Session name is "XMLSession1". If a node with the same name already exists as a child, add the node anyway.
<AMXMLCREATENODE XPATH="/bookstore/book/price" NEWNODE="Euro" NEWVALUE="10" INSERTASFIRSTCHILD="YES" />