Using tXMLMap to read XML
This recipe shows how we can convert an XML record stored in a file into a format that is readable by tXMLMap
, and how we can then read and process the data in the XML record.
Getting ready
Open the job jo_cook_ch09_0010_readXMLFile
.
How to do it...
The first stage of this process is to convert the XML file into Java Document format for use by the downstream component.
Drag a
tFileInputXML
component onto the canvas.Edit the schema and add a column named payload. Make it a type of Document, as shown in the screenshot:
Open the
tFileInputXML
component and change the File name/Stream field tocontext.cookbookData+"/chapter9/chapter09_jo_0010_customerData.xml"
.Change the Loop Xpath query field to
"/"
.Add an Xpath query of
".",
and tick the box Get Nodes.Your
tFileInputXML
should look like the one shown in the next screenshot:Reading using tXMLMap
Add a
tXMLMap
component to the canvas and link to thetFileInputXML
component.Open the
tXMLMap
component and right-click on payload...