XML Loop

<< Click to Display Table of Contents >>

Navigation:  Actions > XML Documents >

XML Loop

The XML Loop allows to get the information about nodes of the document in a loop. When of every cycle iteration it is possible to save various parameters of the node and the node itself into variables. By means of the XML Loop it is possible to analyze or to process the information enclosed in XML.

If you want to retrieve and process some single node use XML Get Single Node action

 

General parameters

XMLLoop1

 

 

XML File

Read XML from file. This option is recommended if XML contain encoded strings. When the action reads it from file it decodes all encoded strings automatically.

The most popular UTF-8 encoding. XML file should have corresponding header. For example:

<?xml version="1.0" encoding="utf-8"?>

 

XML

Specify the XML text which you want to analyze. The text can be specified explicitly or with using of variables.

 

Node Path from Root

The Node Path is a criterion of selecting of loops from an XML document.

Specify a path of nodes from/of a root that you want to enumerate. It is possible to use mask symbols:

? -  means any single symbol.

* - means arbitrary number of symbols.

Instances of usage:

*\*\description

breakfast_menu\*\description

breakfast_menu\food\description

breakfast_menu\food\*

If you want to enumerate all nodes beginning from a root, specify just the symbol "*" with switched parameter With Subnodes.

 

With Subfolders

If you want to enumerate all nodes including nested nodes, switch on this checkbox.

 

Save Node Text to variable

If you need to save a node text, switch on this checkbox and enter the variable name.

 

Save node parameters

The rest of node parameters are collected in this group of parameters.

XMLLoop2

 

 

Save XML Node to Variable

To save the whole node, switch on this checkbox and enter the variable name.

 

Save Node Name to Variable

To save the node name, switch on this checkbox and enter the variable name.

The fact of the matter is that sometimes you cannot know a node name beforehand. For example, this is possible when you select nodes according a mask:

breakfast_menu\food\*

 

Save Node Path to Variable

To save the path of a node, switch on this checkbox and enter the variable name.

 

Save Node Depth to Variable

To save the depth of enclosure of the node, switch on this checkbox and enter the variable name. A node depth is a number, 0 corresponds to a root element.

 

Save Child Count to Variable

To save quantity of child nodes, switch on this checkbox and enter the variable name.

 

Save Node Attributes

XMLLoop3

 

 

On this tab one can specify the attributes which values are necessary to be saved into variables. It is necessary to specify parameters for every attribute:

Name - The attribute name

Variable - The name of the variable in which it is necessary to save the attribute value.

Default value - The value which is written into a variable if the attribute is absent.

 

 

note Related Topics

XML Create Node

XML Add Childnode

XML Save

XML Get Single Node