How to automatically convert XML data files to lists and export to CSV/XLS/XLSX

If you have an XML file and would like to convert its data automatically to a list, follow the below steps:

1. Download the ZIP file from here.

2. Under Flows > Tests, click on Import. A new window will appear; click on Select a File and import the file you downloaded in point 1. 

3. Search for xml_converter, then click on the result to open the test case.

4. Click on the caption of the first step in the test case, which is a Command Template (a parameterized function). 

5. The right panel will open where you'll see the parameters that need to be specified.

6. The JAR snippet is encapsulated in the function. Please refer to the details below:

  • XML_CONVERTER_XML_FILE_PATH - The local path to the XML file. For example: C:\myfolder\myfile.xml for Windows, or /home/xpoint/Downloads/your_xml_file.xml for Linux
  • XML_CONVERTER_OUT_LIST_VAR_NAME - The variable name for the output list where the extracted data will be stored
  • XML_CONVERTER_XML_PATH - The XML path used to retrieve the nodes array. For example: /DataRoot/Element/*
  • XML_CONVERTER_XML_EXCLUSION_NODES_NAMES (optional): A comma-separated list of node names to exclude. For example: XYZ_DATA_1,USER_PROFILE,ORDER_DATA,TRANSACTION_LOG

7. When you specify the parameters above and run the test case, the extracted data will automatically be added to a list. You can view this list in the right panel under the Variables tab by clicking the three dots.

8. If you'd like to export the data to an XLS, XLSX, or CSV file, you'll need to take an additional step: add a Write command. 

9. Click the List option under Source Type, and call the List Variable by entering the '@' sign and select the same variable name specified in XML_CONVERTER_OUT_LIST_VAR_NAME.

Note: You can select XLS, XLSX, or CSV from the Type field. 

Note: You can select your Location as follows:

  • S7 Storage: This uploads the file to the Subject7 repository where you can download it when needed.
  • Remote: This uploads the file to SharePoint but this requires extra setup. Please navigate to this article to read more about this.
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.