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.

  1. Create and name the automation as XML_updatenode.
  2. Start an XML session by using the XML > Start session action.
    1. In the Session name field, enter Default.
    2. 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.
  3. Double-click or drag the Update node action into the editor.
    1. In the Session name field, enter Default.
    2. In the XPath Expression field enter //Customer/Cust_Details/custzipcode.
    3. In the New value field, enter 15867
  4. 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.