XML - Delete node
Declaration
<AMXML ACTIVITY="delete_node" XPATH="text" ATTRNAME="text" SESSION="text" />
Description
Deletes all the nodes/attributes that match the Xpath expression in a given XML file.
IMPORTANT: The use of Automate Desktop's
XML activities requires a fundamental understanding of XML schema and
general knowledge of XML-related terms, such as Nodes, XPath,
DTD and XSLT.
Practical usage
Used to remove a specified node. When a node is removed, all its child nodes are also removed.
Parameters
Session
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Session | Text | Yes | XMLSession1 | SESSIONNAME="myXMLSession" | The name of an existing XML 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 instead of the original. 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 delete. |
Attribute (optional) | Text | No | (Empty) | ATTRNAME="attributeName" | The attribute in which to delete. |
Example
NOTE:
- Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
- To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.
Description
This sample task deletes nodes at XPath /bookstore/book/price/Euro.
Copy
<AMXML FILE="XMLFile" SESSION="XmlSession1" />
<AMXML ACTIVITY="delete_node" XPATH="/bookstore/book/price/Euro" SESSION="XmlSession1" />
<AMXML ACTIVITY="end_session" SESSION="XmlSession1" />