Table of Contents

Search

  1. Preface
  2. The Transformation Language
  3. Constants
  4. Operators
  5. Variables
  6. Dates
  7. Functions

Transformation Language Reference

Transformation Language Reference

PARSE_XML

PARSE_XML

Parses XML hierarchical data in a string data type and generates a struct. The struct schema is based on the specified complex data type definition that you pass in the argument. This function is appropriate when you receive hierarchical data midstream in the mapping, and need to parse the data for downstream processing.

Syntax

PARSE_XML(upstream_string,:Type.type_definition_library.type_definition)
The following table describes the arguments for this command:
Argument
Required/Optional
Description
upstream_string
Required
The source string field, midstream in the mapping, that contains hierarchical data in XML format.
:Type.type_definition_library.type_definition
Required
The complex data type definition that represents the schema of the struct data.
Use the reference qualifier
:Type
to reference the type definition library that contains the complex data type definition.

Return Value

Struct.

Examples

The following expression generates a struct based on the specified complex data type definition
customer_def
.
PARSE_XML(upstream_string,:Type.type_definition_library.customer_def)
The following example shows XML data in the upstream fields, assigned as a string data type:
<Customers> <Customer> <CustName>ABC Co</CustName> <Contract>1010</Contract> <City>Phoenix</City> <SaleAmt>150000.00</SaleAmt> </Customer> <Customer> <CustName>Data Inc</CustName> <Contract>1111</Contract> <City>Portland</City> <SaleAmt>20000.00</SaleAmt> </Customer> </Customers>
The complex data type definition
customer_def
is defined in the type definition library as follows:
customer_def{ CustName : string Contract : int City : string SaleAmt : int }
The following table shows how the PARSE_XML function in the mapping expression parses the upstream string using
customer_def
and returns a struct:
CustName
Contract
City
SaleAmt
RETURN VALUE
ABC Co
1010
Phoenix
150000.00
{ CustName:ABC Co Contract:1010 City:Phoenix SaleAmt:150000.00 }
Data Inc
1111
Portland
20000.00
{ CustName:Data Inc Contract:1111 City:Portland SaleAmt:20000.00 }

0 COMMENTS

We’d like to hear from you!