Extract XML Fragment Action

Declaration

<AMXMLEXTRACTFRAGMENT XPATH="text" XMLDESTINATION="text" ROOTNODENAME="text" OVERWRITEFILE="text [options]" />

See Also

Create XML Node Action, Delete XML Node Action

Description

Extracts an XML fragment (i.e. a collection of nodes) located at the specified XPath and saves it to a new file.

Practical Usage

See description.

Parameters

General Tab

XPath expression

Text, Required
MARKUP: XPATH="/BookStore/Books"

Specifies the Xpath expression to the node which you want to fragment from the current XML document.

Output File

Text, Required
MARKUP: XMLDESTINATION="C:\ExtractedXML.xml"

Specifies the file in which you want to store the fragment as a first child of root node.

Root node name for output

Text, Required
MARKUP: ROOTNODENAME="RootNodeName"

Specifies the name of the root node for the new XML file.

Overwrite if File Exists

Yes/No, Optional - Default "NO"
MARKUP: OVERWRITEFILE="YES"

If set to Yes, specifies that if the file already exists, it will be overwritten with the new document. If set to No, the step fails if the file already exists.

Session Name

Text, Optional - Default "XMLSession1"
MARKUP: SESSIONNAME="FirstXMLSession"

Specifies the session name to identify the in-memory XML document to use in subsequent XML steps. This allows several in-memory XML documents to be active simultaneously.

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<AMXMLEXTRACTFRAGMENT XPATH="/BookMarks/Money" XMLDESTINATION="C:\Output.xml" OVERWRITEFILE="YES" ROOTNODENAME="Automate" SESSIONNAME="XML1" />