|
XML - Extract node |
Declaration
<AMXML ACTIVITY="extract_node" SESSION="text" FILE="text" XMLDOCUMENTFROM="text (options)" XMLTEXT="asdf" OVERWRITEFILE="YES/NO" ROOTNODENAME="text" NEWVALUE="text" DEFAULTNSPREFIX="text" DEFAULTNAMESPACE="text" XPATH="text" RESULTDATSET="text"><ATTRIBUTE NAME="text" VALUE="text" /><NAMESPACE PREFIX="text" URI="text" /></AMXML>
Description
Extracts the XML node's children and their corresponding values located at the position expressed by the XPath and then creates and populates a dataset with the results.
IMPORTANT: The use of Automate'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
See Description.
Parameters
Resource
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Resource | --- | --- | --- | --- | Denotes
where the XML data should originate from. This is a visual mode
parameter used only during design-time, therefore, contains no
properties or markups. The available options are:
|
Session | Text | Yes, if Resource parameter is set to Session | XMLSession1 | SESSIONNAME="myXMLSession" | The name of an existing 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 related steps are performed on a copy of the XML data saved to memory. Use the XML - Export 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. |
Create XML session from | Text (options) | Yes, if Resource parameter is set to File | Existing file |
|
Specifies
where the XML data should derive from. The XML data will be saved
into memory. Different parameters become active depending on which
option is selected. The available options are:
|
File | Text | Yes, if session created from a new or existing file | (Empty) | FILE="c:\foldername\file.XML" | The path and file name of the new or existing XML file. This parameter is active only if the Create XML session from parameter is set to Existing file or New file. |
Overwrite if file exists | Yes/No | Yes, if XML session derives from a new file | No | OVERWRITEFILE="YES" | If selected, specifies that if an XML file with the same name already exists at the specified location, it will be overwritten with the new file. If disabled (default), the step fails if the file already exists. This parameter is active only if the Create XML session from parameter is set to New file. |
Root node name | Text | Yes, if XML session derives from a new file | (Empty) | ROOTNODENAME="Automate" | The root node name for new XML file. This parameter is active only if the Create XML session from parameter is set to New file. |
Root node value (optional) | Text | No | (Empty) | NEWVALUE="Value" | The root node value for the new XML file. This parameter is active only if the Create XML session from parameter is set to New file. |
Default namespace prefix (optional) | Text | No | (Empty) | DEFAULTNSPREFIX="edi" | The prefix of the default namespace for the new XML file. A namespace prefix is a text string assigned as an element name prefix to a namespace. When an element name is preceded by the prefix and a colon, then that element is in that assigned namespace. This parameter is active only if the Create XML session from parameter is set to New file. |
Default namespace URI (optional) | Text | No | (Empty) | DEFAULTNAMESPACE="http://net.com/schema" | The default namespace URI for the new XML file. An XML namespace is a collection of element type and attribute names that are uniquely identified by the name of the unique XML namespace of which they are a part. This parameter is active only if the Create XML session from parameter is set to New file. |
Attribute Name | Text | No | (Empty) | NAME="AttribName" | The name portion of the attribute name-value pair to insert. Use this parameter to insert attributes into the new node. To enter a new row of values select Click here to add new row. To delete an existing row, click the red "X." This parameter supports insertion of multiple attribute name value pairs. |
Attribute Value | Text | No | (Empty) | VALUE="AttribValue" | The value portion of the attribute name-value pair to insert. Use this parameter to insert attributes into the new node. To enter a new row of values select Click here to add new row. To delete an existing row, click the red "X." This parameter supports insertion of multiple attribute name value pairs. |
Text | Text | Yes, if XML session derives from text | (Empty) | XMLTEXT="theText" | The text that the XML data should originate from. This parameter is active only if the Start XML session from parameter is set to Text. |
Namespace Prefix | Text | No | (Empty) | PREFIX="PrefixName" | The prefix associated to the added namespace. Use this parameter to insert namespace prefix and URI values into the new node. To enter a new row of values select Click here to add new row. To delete an existing row, click the red "X." This parameter supports insertion of multiple namespace prefixes and URIs. |
Namespace URI | Text | No | (Empty) | URI="URIName" | The URI associated to the added namespace. Use this parameter to insert namespace prefix and URI values into the new node. To enter a new row of values select Click here to add new row. To delete an existing row, click the red "X." This parameter supports insertion of multiple namespace prefixes and URIs. |
Node
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
XPath expression | Text | Yes | (Empty) | XPATH="sum(//price/text())" | The XPath expression from the current XML document in which to retrieve values from. |
Create and populate dataset with node properties | Text | Yes | (Empty) | RESULTDATASET="theDataset" | The name of the dataset to use to create and populate with the node's properties. |
Example
NOTE:
- The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
- Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.
Description
This sample task extracts a node's children and their corresponding values and then creates and populates a dataset with the results.
Copy
<AMXML FILE="XMLFile" SESSION="XmlSession1" />
<AMXML ACTIVITY="extract_node" SESSION="XmlSession1" XPATH="/bookstore" RESULTDATSET="dataSet" />
<AMXML ACTIVITY="end_session" SESSION="XmlSession1" />