Dynamic data import / export


simply more productive
Download full trial Version

General example of processing XML files

We wish to illustrate the general methods of XML processing using the XML Adapter with the following example. All the examples described here are available as complete Definition files in the downloaded zip archive.

We begin with a simple conversion of a CSV file to XML and later describe the processing of more complex XML structures.

Converting CSV text files to XML

Adopt CSV fieldsAdopt CSV fieldsIt is relatively simple to convert CSV text files into flat XML structures. Create a new Definition and select the TextFile Adapter for reading a CSV file on the READ side and the XML Adapter for writing the XML file on the WRITE side. Open the Configurator popup for the TextFile Adapter and identify the CSV text file that is to be converted to an XML file.
Close the Configurator for the TextFile Adapter with OK. Now go to the XML Adapter on the WRITE side and select from the context menu (right mouse click on the XML Adapter ) the option “Adopt the READ fields”. This will transcribe the CSV field names to the XML structure to be written.
When you now click the Designer function "Edit->Automatically connect fields" all fields on the READ side will connect to the WRITE side and the CSV to XML conversion is now ready to run. To demonstrate further possibilities we will now adjust the default settings.

Enhance the XML output

Customize XML field names and attributesCustomize XML field names and attributesWith default settings the XML file will be generated with a root element that encloses the whole file and each CSV row as an XML Element (record). Our first task is to name these as "orders" for the root and "order" for each individual record.

Note: The field names used here are those found in the example "csv-to-xml-conversion.fhd" in the downloaded zip archive.

You will note that this results in two mentions of "order" as field names in the XML output. Firstly as the XML Element name for each CSV row and secondly as the field name for the order number. This order number we shall now amend in the XML Attribute. Edit the field name from "order" to "number"  and additionally amend the "Node Type" from "Node" to "Attribute". As a further gimmick amend the "Node Type" for "Customer" from "Node" to "Comment" to observe what happens.

XML outputXML outputClose the Configurator with OK and run the Definition. You should obtain the output shown. As you can see, there is an XML Attribute for each order number as well as the customer name is output as a comment.

Importing XML files

Available shortly

Exporting complex XML structures

Available shortly