Don't get lost: Training » Homework » XML datasources

XML Datasources

Estimated time: 45 Mins

In this step we will create a ‘Reader’ transform to pull data from an XML file.

Introduction to XML

  1. Xml Data
  2. IMan Xml Parsing

Method

  1. Setup an XML Reader
  2. Create Parent Transaction Type
  3. Create Children Transaction Types

Xml Data

Xml is a self-describing, hierarchical data format. Xml is extremely easy to work with since:

  • Xml parsers validate the data syntax on load. Additional validation can be enforced through Xml schema(s).
  • Fields & record types can be added without breaking the existing setup.

IMan Xml Parsing

XML is parsed into three sections:

  1. Entry Point
    1. This is a header node(s), before the first repeating node begins.
  2. Top Record Type
    1. The node(s) used to identify the top repeating transaction type.
  3. Children Transaction Type
    1. The node(s) used to denote the children records. An unlimited amount of children arranged in virtually an unlimited nesting (max. 64 children transactions).

The Xml Read transform requires you to define the data schema. The other Read types (CSV, Database, Excel and SageCRM) auto-parse their respective input data to determine their schema.

Setup an XML Reader

  1. Create a new integration.
  2. Click on the Transform Setup tab
  3. Click on Readers
  4. Drag an XML Reader onto the design palette

  1. Double click to open the transform set up screen:

  1. Transform Id
    1. A unique and recognisable Id used to identify the transform.
    2. The value is displayed in the detail section of the audit report.
  2. Data Source
    1. Either File or Http.
    • For training: File
  3. File Path
    1. A path to where the files are located.
    • For training, enter: C:\IMan\InputData\Training
  4. File Name
    1. Can be either a static value or can contain the wildcards ‘*’ or ‘?’.
    • For training, enter: XmlDatasourceInput.xml
  5. Encoding Method
    1. The text encoding is the numeric representation of a character. There are 100’s of encodings, IMan supports the most common
    2. Typically Xml files are UTF8 (the common web format); most text files are ASCII.
    • For training: UTF-8
  1. Press the green tick to save.
  2. Pressing refresh will throw an error, as IMan we have not yet told IMan how to interrogate the XML data. This we will do in the next step.

Create Parent Transaction Type

Hierarchical data is supported intrinsically throughout IMan. Each transform must have 1 parent transaction type. The parent transaction type may have an unlimited amount of children transaction types, which can have children and so on.

  1. Open the field mapping tab, and enter the following:

  1. XML entry point.
    • /fb_sales
  2. Enter the parent record id and press the Add ‘>’ button.
    • For training, enter: Orders
  1. Press the edit button to add fields to the record type:
  1. Enter the relative XPath of the transaction type.
    • sales_order
  1. Double click the empty row at the top of the grid to create a new field:
  1. Enter a unique id for the field
    • OrderType
  2. enter the nodes used to identify the value
    • order_type
  3. change transaction type accordingly
    • Text
  4. Press the green tick to save the field.
  1. Repeat for each field in the order. Open up the XML input data file if necessary.

The customer fields are represented in their own node; so be sure to enter the node path correctly).

  1. Enter the node(s) to indicate the repeating structure:

  1. Once the fields have been entered press Save. You can then (finally!) press Refresh to see if the data can be retrieved.

Create Children Transaction Types

  1. Enter a unique Id and press the add button.
  2. For nested structures ensure the parent transaction type is set correctly.
  3. Press the edit button to display the field list.
  1. Enter the relative XPath of the transaction type.
  2. Enter the Transaction XPath.
    • Training: order_details/item
  3. Enter each of the fields, as before.

  1. Press save, and refresh:

  1. Once this is complete, close the setup screen and press Save on the main design screen.