Delete node action in XML
- Updated: 2024/11/29
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.
- Create a bot.
- On the left panel, click Automation.
A list of available bots and forms is displayed.
- Click Create a bot.
- Enter the bot name: XML_bot.
- Click Create and Edit.
- On the left panel, click Automation.
- Double-click or drag the Start session
action from the XML
package in the Actions palette.
- Enter Default in the session name field.
- 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>
- Double-click or drag the Delete node
action from the XML
package in the Actions palette.
- Enter Default in the session name field.
- Enter //note/to in the XPath expression field.
- Enter company in the Attribute (optional) field.
- Double-click or drag the Save session data
action from the XML
package in the Actions palette.
- Enter Default in the session name field.
- Select the Write XML data option and specify a file path. For example, D:\userdefined\Delete_node.xml.
- Select Overwrite to replace the existing file if a file with the same name exists in the location you have specified.
- 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>