Update node action in XML
- Updated: 2025/05/26
Update node action in XML
The Update node action in the XML package enables you to update the value of a node.
Note: When you use the Update node action, the
attributes are alphabetically sorted and displayed in the XML output.
Settings
- Use the Session name field to enter an XML session that you
have used in the Start XML session
action.
(Optional) Select an existing variable used in the Start XML session action.
- Use the XPath expression field to enter the node that must be
updated.
For example, //bookstore/book. If you have stored the node value as a variable, click the Insert a value icon to select it.
- Use the New value field to enter the value that must be
updated in the selected node.
(Optional) If you have stored the node value that must be updated as a variable, click the Insert a value icon to select it.
- (Optional) Select the Updates attribute (s) check box.Use the Attributes field to select one of the following tabs:
- Dictionary: To create a new Dictionary-type, click Add.
- Variable: To select an existing variable.
Example for updating a node
Consider a sample XML called Cust_details.xml
with the following structure:
<Customer>
<Cust_Details>
<custid city="Leon">A001</ custid>
<custname>XYZ Corp</custname>
<custzipcode>15639</custzipcode>
<country>Mexico</country>
<Locale lang=”es”> Spanish</Locale>
</Cust_Details>
</Customer>
Consider a scenario where you want to update the value of <custzipcode> to 15867 in the Cust_details.xml file.
- Create and name the automation as XML_updatenode.
- Start an XML session by using the action.
- In the Session name field, enter Default.
- In the Data Source field, choose File and select the Desktop file option. Click Browse to locate your Cust_details.xml file. For example: D:\XML_files\Cust_details.xml.
- Double-click or drag the Update node
action into the editor.
- In the Session name field, enter Default.
- In the XPath Expression field enter //Customer/Cust_Details/custzipcode.
- In the New value field, enter 15867
- Click Save and then click Run.
Note: The node is updated during automation runtime. However, if you
want to save the data, you can use the Save session data
action. See Save session data action in XML.