XML Flattener
The XML Flattener processor flattens a well-formed XML document embedded in a string field and adds the flattened data to the record as additional fields or as a map in a single field.
When you configure the XML Flattener, you specify the field that contains the XML data. You can specify a record delimiter to generate multiple records from the XML document. When specifying a record delimiter, use an XML element directly under the root element.
You can configure whether the processor keeps all fields in the original record, or keeps just the flattened fields.
You can also specify an output field. When you define an output field, the processor writes the flattened fields to the output field as a map. You can optionally configure the string used to separate entity names and attributes in the flattened field names.
Generated Records
The XML Flattener generates multiple records from a well-formed XML document based on a user-defined record delimiter. The delimiter specifies the XML element to use to create records. Use an XML element directly under the root element.
When no record delimiter is defined, the processor reads the entire contents of the field as a single record.
For example, a string field contains the following XML:
<contacts>
<contact>
<name type="maiden">NAME1</name>
<phone>(111)111-1111</phone>
<phone>(222)222-2222</phone>
</contact>
<contact>
<name type="maiden">NAME2</name>
<phone>(333)333-3333</phone>
<phone>(444)444-4444</phone>
</contact>
</contacts>
If you specify the contact
element as the record delimiter, the XML
Flattener creates two records. Record 1 contains the following fields:
contact.name: NAME1
contact.name#type: maiden
contact.phone(0): (111)111-1111
contact.phone(1): (222)222-2222
Record 2 contains the following fields:
contact.name: NAME2
contact.name#type: maiden
contact.phone(0): (333)333-3333
contact.phone(1): (444)444-4444
If you do not specify a record delimiter, the XML Flattener creates one record that contains the following fields:
contacts.contact(0).name: NAME1
contacts.contact(0).name#type: maiden
contacts.contact(0).phone(0): (111)111-1111
contacts.contact(0).phone(1): (222)222-2222
contacts.contact(1).name: NAME2
contacts.contact(1).name#type: maiden
contacts.contact(1).phone(0): (333)333-3333
contacts.contact(1).phone(1): (444)444-4444
Configuring an XML Flattener Processor
Configure an XML Flattener to flatten XML data embedded in a string field.