XML - Edit node

Declaration

<AMXML ACTIVITY="edit_node" NEWVALUE="text" EDITNODE="text (options)" SESSION="text" />

Description: Edits a node value or its attribute in a given file. Select the appropriate node using Xpath expression. Note that the action will edit the first node if Xpath evaluates to more than one node.

IMPORTANT: Use of XML activities require a basic understanding of XML and related terms, such as XPath, DTD and XSLT.

Practical Usage

See description.

Parameters

Session

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

Property

Type

Required

Default

Markup

Description

XPath Expression

Text

Yes

(Empty)

XPATH="/BookStore/Books/Price"

 The Xpath expression to the XML node in which to edit.

Attribute (optional)

Text

No

(Empty)

XMLATTRIBUTE="Price"

Tells the XML node the value of the attribute to edit.

Value

Text

No

(Empty)

NEWVALUE="NewValue"

The XML node's attribute to edit.

Apply text to node(s) only

Yes/No

No

Yes

APPLYTOTEXTNODE="NO"

If set to YES, text will be applied to the node(s) only.

Edit mode

Text (options)

No

First

EDITNODE="All"

Specifies whether the first node or all nodes are to be edited. The available options are:

  • First (default) - The first node will be edited.

  • All - All nodes will be edited.

 

Description

Error Causes

On Error

Example

NOTE: The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description: Edit XML node at XPath location "/BookStore/Book". Session name is "XMLSession1". Edit first node(s).

<AMXMLEDITNODE XPATH="/BookStore/Book" NEWVALUE="Who moved my Cheese" />