Delete node action in XML

The Delete node action in the XML package enables you to delete a specific node from XML file.

Settings

  • Enter the session name or select an existing variable used in the Start XML session action.
  • Enter the XPath expression for the node to be deleted.
  • Enter the attribute (optional).

Example of using Delete node action

In this example, you will create an automation that deletes a specified node from the XML.

  1. Create a bot.
    1. On the left panel, click Automation.

      A list of available bots and forms is displayed.

    2. Click Create a bot.
    3. Enter the bot name: XML_bot.
    4. Click Create and Edit.
  2. Double-click or drag the Start session action from the XML package in the Actions palette.
    1. Enter Default in the session name field.
    2. From the Data source field, select Text option and enter the following text:
      <note>
      
      <to company = "AA">Tove</to>
      
      <from>Jani</from>
      
      <heading>Reminder</heading>
      
      <body>Don't forget me this weekend!</body>
      
      </note>
  3. Double-click or drag the Delete node action from the XML package in the Actions palette.
    1. Enter Default in the session name field.
    2. Enter //note/to in the XPath expression field.
    3. Enter company in the Attribute (optional) field.
  4. Double-click or drag the Save session data action from the XML package in the Actions palette.
    1. Enter Default in the session name field.
    2. Select the Write XML data option and specify a file path. For example, D:\userdefined\Delete_node.xml.
    3. Select Overwrite to replace the existing file if a file with the same name exists in the location you have specified.
  5. Click Save and then Run.
When you open and edit the file Delete_node.xml in Notepad++, you will see that the attribute company has been deleted from the file.
<?xml version="1.0" encoding="UTF-8"?>
<note>

<to>Tove</to>

<from>Jani</from>

<heading>Reminder</heading>

<body>Don't forget me this weekend!</body>

</note>