Create XML Node

Creates a new node in an existing XML file. Optionally assigns a value and attribute to the node. Used to create a new node or modify an existing node in a document tree.

AWE's XML actions require a basic understanding of XML and related terms, such as XPath, DTD and XSLT.

Declaration

<AMXMLCREATENODE XPATH="text" NEWNODE="text" NEWVALUE="text" NODEWITHSAMENAMEEXISTTHEN="test (options)" DEFAULTNAMESPACE="text" DEFAULTNSPREFIX="text" INSERTAT="text (options)"><Attribute Name="text" Value="text" /></AMXMLCREATENODE>

Example

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" />

See Also: Dataset to XML, Delete XML Node, Edit XML Node, End XML Session, Evaluate Xpath Expression, Extract XML Fragment, Merge XML Files, Output XML, Read XML Node, Sign XML Document, Start XML Session, Transform XML, Validate XML File, Verify XML Document, XML Node to Dataset

General Tab

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

NODEWITHSAMENAMEEXISTTHEN="Skip"

Specifies what to do if a node with same name as the one being inserted at the current location already exists. The available options are:

  • Ignore (default): Directs the action to create a new node regardless of whether other nodes with the same name exist. Ignore is the Default

  • Skip: Directs the action to skip a child node if any child nodes exist with the same name as the new node.

  • Overwrite: Directs the action to overwrite any child nodes it finds that have the same name as the new node. If multiple child nodes with the same name exist, the action creates only one of them and erases the rest.

  • Fail: Tells the action that if any child nodes exist with the same name, the action will fail.

Insert as first child node

Yes/No

No

No

INSERTASFIRSTCHILD="YES"

If set to YES, allows you to insert the new node as a first child of the parent node found using Xpath Expression. The default value is set to NO..

Session Name

Text

No

XMLSession1

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.

Attributes Tab

Property

Type

Required

Default

Markup

Description

Default namespace (optional)

Text

No

(Empty)

DEFAULTNAMESPACE="default"

The default namespace. This parameter is optional.

Prefix for default namespace (optional)

Text

No

(Empty)

DEFAULTNSPREFIX="thePrefix"

The prefix associated to the default namespace.

Insert node at

Text (options)

No

Beginning of child nodes

INSERTAT="after"

Specifies where to insert the node onto the child node. Other parameters may become active depending on which option is selected. The available options are:

  • Beginning of child nodes (default)

  • End of child nodes

  • After specified child node

  • Before specified child node

Specified child node name

Text

No

(Empty)

SPECIFIEDNODE="nodeName"

The name of the child node. This option is active only if the Insert node at parameter is set to After specifies child node or Before specified child node.

If specifies child node does not exist

Text (options)

No

Skip

SPECIFIEDNODENOTEXIST="fail"

Specifies what to do if the specified child node does not exist. This option is active only if the Insert node at parameter is set to After specifies child node or Before specified child node. The available options are:

  • Skip

  • Fail

  • Insert at beginning of child nodes

  • Insert at end of child nodes

Attributes Tab

Use these properties to insert attributes into the new node.

Property

Type

Required

Default

Markup

Description

Attribute Name

Text

No

(Empty)

Name="AttributeName"

The name of the attribute to insert. Once you have specified an attribute name/value, use the following buttons if needed:

  • Move Up - Move the attribute up one line.

  • Move Down - Move the attribute down one line.

  • Add - Once you have given the Attribute Name and Value, click this button to add them to list.

  • Remove - Use this to remove existing attribute names/values.

Attribute value

Text

No

(Empty)

Value="AttributeValue"

The value of the attribute. Once you have specified an attribute name/value, use the following buttons if needed:

  • Move Up - Move the attribute up one line.

  • Move Down - Move the attribute down one line.

  • Add - Once you have given the Attribute Name and Value, click this button to add them to list.

  • Remove - Use this to remove existing attribute names/values.

Namespace Tab

Use these properties to insert namespace prefix and URI into the new node.

Property

Type

Required

Default

Markup

Description

Prefix

Text

No

(Empty)

PREFIX="PrefixName"

The prefix associated to the added namespace. Once you have specified namespace properties, use the following buttons if needed:

  • Move Up - Move the namespace up one line.

  • Move Down - Move the namespace down one line.

  • Add - Add the namespace to the list.

  • Remove - Remove existing namespce from the list.

Namespace URI

Text

No

(Empty)

URI="URIName"

The URI associated to the added namespace. Once you have specified namespace properties, use the following buttons if needed:

  • Move Up - Move the namespace up one line.

  • Move Down - Move the namespace down one line.

  • Add - Add the namespace to the list.

  • Remove - Remove existing namespce from the list.