Reading simple XML files
PDI has a step named Get XML Data used to read XML structures. This recipe shows how to read an XML file containing the information about museums using this step.
Getting ready
In this exercise, you will use a file named museum.xml
with the following structure:
<museums> <museum id_museum= '…'> <name>…</name> <city>…</city> <country>…</country> </museum> </museums>
How to do it...
Carry out the following steps:
Create a new transformation.
Drop a Get XML Data step from the Input category into the canvas.
Under the File tab, you must select the XML document. Browse for the file
museums.xml
and click on the Add button.Under the Content tab, type
/museums/museum
in the Loop XPath textbox. This will be the current node.Tip
Alternatively, you can click on the Get XPath nodes and select it.
Under the Fields tab, you need to specify the fields by using XPath notation. Use the Get Fields button...