This tutorial will demonstrate how to extract sample data from an xml file and read each xml record into a separate output file. The example file we will use is a simple file with the following format:
<field1>Test Data 1</field1>
<field1>Test Data 2</field1>
<field1>Test Data 3</field1>
Firstly we will read the data from the source xml file using the tFileInputXML component:
In our case the xPath query and the Mapping are quite simple, but these could be infinitely more complex depending upon your use case.
After we connect the data flow from the tFileInputXML to the tFlowtoIterate component, we then want to iterate over each record we extract from the XML. We do this by connecting an iterate link from the tFlowToIterate component to a tFixedFlowInput component.
Here we are able to access the value for the current row in the iteration using the globalMap.get method. A shortcut to get values that are being written into the tFlowToIterate component is to type “tFlow” and then press cntrl +space, this will bring up the available data in that component and you can select the field you want.
Next we write the data into an output file and name the output file with the name of the row data string from the current row in the xml file. In our case this will generate 3 output files.
This should give you an idea of how to convert data rows into singular variables / outputs.