Document toolboxDocument toolbox

XML Parser

Description

This unit is a Processor unit type.

The XML Parser unit parses events containing a properly formatted XML, using the Jackson parser.

An event comes in through the in port. The data field content is parsed using Jackson.

Successfully parsed input events are enriched with a new field containing the parse result and are output through the out port.

If an error occurs, the input event is enriched with new fields describing the problem, and the event is sent through the error port.

Configuration

After dragging this unit into the Flow canvas, double-click it to access its configuration options. The following table describes the configuration options of this unit:

Tab

Field

Description

Tab

Field

Description

General

Name

Enter a name for the unit. It must start with a letter, and cannot contain spaces. Only letters, numbers, and underscores are allowed.

Description

Enter a description detailing the scope of the unit.

In field

Enter the name of the input event field containing JSON data.

Out field

Enter a name for the output event field containing the parse result.

Input ports

Port

Description

Port

Description

in

Events containing a properly formatted XML to be parsed.

Output ports

Port

Description

Port

Description

out

Outputs events enriched with an extra field containing the parsed XML.

error

Signals when an error occurred. Outputs input events enriched with standard error fields.

Example

In this example, we want to insert an XML message containing information on threats and parse it to be sent to a my.app data table.

First, we will use a Tick unit to send the fields when clicked.

In the Fields tab of the properties, add the Type as string and enter the following expression in the Value field:

<note> <to>Threat investigator</to> <from>Developer</from> <heading>Comment</heading> <body>A threat has been detected</body> </note>

Then, we will link it to an XML Parser unit in order to parse this string.

In the properties, select the In field as threat to correspond with the field previously set in the Tick. Set a name for the out field, in this case, data.

Next, we use a Map unit to remove and add fields to the parsed message. Link the out port of the XML Parser to the in port.

In the Fields to add tab of the properties, add the following fields:

 

 

In the Fields to remove tab, enter threat and data.

Finally, we will link its out output port to a Devo sink unit to send the formatted events to a my.app table.

Download this example

You can try this flow by downloading this JSON and uploading it to your domain using the Import option:

Â