# XML/JSON Parser

An *XML/JSON Parser* reads and processes a single text stream of hierarchical data and give elements as parsed output in XML/JSON format.

### Sample Use-Case

In this case, we are using an [*Excel Workbook Source*](/dataflows/sources/excel-workbook-source.md).

![](/files/BDOdIYKNpxQfAUFa5Pl9)

The source file contains details of customers’ orders.

To preview data, right-click on the source object’s header and select *Preview Output* from the context menu.

![](/files/xPQKdGw7SYfj6Z014Qrv)

A *Data Preview* window will open, displaying the source data.

![](/files/cZI7N3Ncj8bdW0fxe9yi)

Observe that it is difficult to decipher fields and elements when the data is in a text stream. To make sense of this data, it needs to be structured in a proper format, with fields and collection regions clearly identified.

To parse this source data, we will use *XML/JSON Parser* in Astera.

#### Using XML/JSON Parser

1. To get the *XMl/JSON Parser* object, go to *Toolbox > Text Processors > Parser* and drag-and-drop the object onto the designer.

![](/files/RUGN7onOBsNG8ixEnzgV)

You can see that the dragged object contains a *Text* field.

2. Map the *Text* field in *Customer\_Orders* object to the *Text* field in the *XMLJSONParser* object.

![](/files/0wssuF7TlolI4fNRVAKP)

3. Right-click on the object’s header and select *Properties*.

![](/files/FtzHlGNtfFrelXJdLHgm)

A configuration window will open, as shown below.

![](/files/Ykztdc4SaZQlfuORXdUi)

4. Provide the XML schema path. Astera will parse the text file based on the structure defined in the schema file.

![](/files/rfOZiirpBRmxub2rInOY)

Click *Next*. This is the *Layout Builder* screen where the final layout of the incoming fields and the collection regions can be seen.

![](/files/97WoHVOzrFKPFxtp5OJs)

Click *OK*. The data stream is parsed into regions and fields which can be seen on the *XMLJSON Parser* object.

![](/files/U9lu1h073c15h3r8Mr5F)

5. Right-click on the object’s header and select *Preview Output* from the context menu.

![](/files/LY65m1YYT1nOMehn916R)

A *Data Preview* window will open. Expand the nodes, and you will see the parsed output for each record.

![](/files/3M77U4u8NSG8EfKNdI2Y)

To store this parsed output, write it to a destination file.

6. Right-click on the *Customer\_Orders* node under *XMLJSON Parser* object, go to *Write to > Database Table Destination*. A *Database Table Destination* object is added to the dataflow designer with all fields auto-mapped to it.

![](/files/LLx7RPl2nMMcm8E7Pp5x)

7. Configure settings for the [*Database Table Destination* ](/dataflows/destinations/database-table-destination.md)object.

Learn to configure settings for a *Database Table Destination* from [here](/dataflows/destinations/database-table-destination.md).

8. Click on the ***Start Dataflow*** button placed in the toolbar at the top to create the destination file.

![](/files/6mP449PgL1zq3OaJ3gpU)

A database table will be successfully created, with parsed output in XML format.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.astera.com/dataflows/text-processors/xml-json-parser.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
