XML Variables

(Available from version 7.0 onwards.)

XML variables allow you to load, read, process, and save data stored in XML format.

For instructions on how to create a complex variable, see here.

Prerequisites

To make full use of the XML variables and their methods, some knowledge of the following is required:

  • XML markup language

  • XPath query language

XML Variable Types

Automation Studio provides three types of XML variables, described below.

The examples shown are based on a simple XML file that lists all three members of a country club.

  • XML Document: This type is designed to store the contents of a standard XML file, including the header (e.g. <?xml version="1.0" encoding="UTF-8"?>), and the XML content itself. Methods are provided for uploading XML files to an XML Document variable.

  • XML Element: This type is designed to store the root element of a standard XML file. A method is provided to populate an XML Element variable with the contents of an XML Document variable.

  • XML Node: This type is designed to store nodes (or sections) of XML content. Methods are provided for populating XML Node variables with nodes from XML Elements and from other XML Nodes.

XML Variable Properties

The three XML variable types all share the same set of properties described below. Not all properties are populated or relevant for all types. See the examples below the table for more information.

Property

Type

Description

Can Be Modified

Exists Boolean

Indicates whether data was found with which to populate the variable when using the method of another variable.

Returns true if the variable was populated with data. Returns false if no data was found with which to populate the variable.

No
Inner XML Text The XML content of all child nodes of the variable. Yes
Name Text The name of the outer node in the variable, or in other words, the outermost XML tag of the XML in the variable. No
Outer XML Text The XML content of the variable. No
Value Text   Yes

Example of XML Variable Types and Properties

This example is designed to clarify the role of the three XML variable types and the meaning of each of their properties. The example uses a limited number of the methods provided. See the example provided for each method here.

Sample Implementation

To see a full project in which data from an XML file is parsed and used to populate a list variable, see Project: Read Data from an XML File.

Methods

The three XML variable types share most of their methods. Some methods are available for one XML variable type only. The table below lists all methods and indicates which methods are available for each variable type. It also indicates the return type of each method.

Method

Returns

XML Document

XML Element

XML Node

Elements By Tag Name List of XML Nodes No Yes No
Get Attribute by Name XML Node Yes Yes Yes
Get Attributes List of XML Nodes Yes Yes Yes

Information on Examples for Methods

An example implementation is shown for each method listed below. All examples are included in the sample project. The sample project includes one workflow per method.

Download the sample project here and unzip to the folder %AppData%/Nice_Systems/AutomationStudio/Projects.

Download the sample XML file here and copy it to the folder c:/Temp.

Methods