Project: Read Data from an XML File
This scenario demonstrates how to read information stored in an XML file and populate a list variable so that the data can be used within an automation solution.
For information about XML variable types and their methods, see here.
Scenario Overview
In this scenario, the solution reads the information included in the XML file shown below. This file includes data on three different members of a country club.
<?xml version="1.0" encoding="UTF-8"?> <members clubName="The Parktown Club" city="Parktown"> <member level="Gold" type="family"> <surname>Smith</surname> <joined>2008</joined> </member> <member level="Silver" type="single"> <surname>Cheketri</surname> <joined>2013</joined> </member> <member level="Silver" type="family"> <surname>Peters</surname> <joined>2001</joined> </member> </members>
The solution will populate a list variable with the member data. Once XML data has been inserted into a list variable, it can then be used by an automation solution, for example, to write data to an Excel file or display it to an agent in a callout.
Download Project Files
-
Download the project file here.
-
Unzip and copy the files to the folder %AppData%/Nice_Systems/AutomationStudio/Projects.
-
Download the XML file here.
-
Unzip and copy the XML file to the folder c:/Temp.
Recommended Implementation Approach
This scenario follows the implementation steps below:
-
Load the XML file into an XML document variable.
-
Extract the root node of the XML document into an XML element variable.
-
Extract the member nodes of the XML element and store them in an XML nodes list variable.
-
Extract information from each XML node to populate one element of a member list variable.
-
Test the solution.
Implementation
The video below demonstrates the full implementation of the project solution.