For the complete documentation index, see llms.txt. This page is also available as Markdown.

Read XML

XML data sources ..

Workshop - Read XML

Get Data from XML

Workshop files

Download these files before you start:

  • The sample XML input.

  • The starter transformation (optional).

Open

Read XML

Create a new transformation

Use any of these options to open a new transformation tab:

  • Select File > New > Transformation

  • Use Ctrl+N (Windows/Linux) or Cmd+N (macOS)


XML - File

In this workflow, an XML file is parsed via XPath to retrieve the dataset.

Get data from XML - file
orders.xml

Get data from XML

This step provides the ability to read data from any type of XML file using XPath specifications.

  1. Start Pentaho Data Integration.

  1. Drag the ‘Get data from XML’ step onto the canvas.

  2. Double-click on the step, and configure the following properties:

XML - file
  1. Click on the Content tab, and configure the following properties:

XPath
  1. Click on the Fields tab, and then on the ‘Get Fields’ button.

XML - fields
  1. Click OK.

Dummy

The Dummy step does not do anything. Its primary function is to be a placeholder for testing purposes. For example, to have a transformation, you need at least two steps connected to each other.

  1. Drag a ‘Dummy’ step onto the canvas.

  2. Create a hop from the ‘Get data from XML’ step.

  3. Close the Step.

RUN Transformation

The workshop illustrates how to ingest an XML data source. The XML can either stream from:

  • a previous step (typically a URL)

  • a file

  • a stream field (XML stored in a field)

  1. Click the Run button in the Canvas Toolbar.

  2. Preview the data.

Preview data

In this workflow, a URL to an XML data source is parsed via XPath to retrieve the dataset.

Get XML - URL

Generate rows

Generate rows outputs a specified number of rows. By default, the rows are empty; however, they can contain several static fields. This step is used primarily for testing purposes. It may be useful for generating a fixed number of rows, for example, you want exactly 12 rows for 12 months.

  1. Drag the ‘Generate Rows’ step onto the canvas.

  2. Double-click on the step, and configure the following properties:

Pass URL in data stream field

Get data from XML

The dataset is being parsed from a stream field xmlUrl that’s being passed on from the ‘Pass URL’ step.

  1. Drag the ‘Get Data from XML’ step onto the canvas.

  2. Create a hop from the ‘Pass URL’ step.

  3. Double-click on the step, and configure the following properties:

Read URL
  1. Click on the ‘Content’ tab and configure the following properties:

Select XPath
  1. Click on the ‘Fields’ tab and configure the following properties:

Configure fields
  1. Click on the ‘Get Fields’ button.

Next: open the Dummy tab.

Dummy

The Dummy step does not do anything. Its primary function is to be a placeholder for testing purposes. For example, to have a transformation, you need at least two steps connected to each other.

  1. Drag a ‘Dummy’ step onto the canvas.

  2. Create a hop from the ‘Get data from XML’ step.

  3. Close the Step.

RUN the Transformation

  1. Click the Run button in the Canvas Toolbar

Invalid data type
  1. Check the logs.

Logs
  1. Change Zone data type to string and re-run transformation.

  2. Click on the Dummy step and Preview data.

Preview Plant Catalog

Last updated

Was this helpful?