Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parse XML docs #6822

Merged
merged 7 commits into from
Apr 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions _data-prepper/pipelines/configuration/processors/parse-xml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
layout: default
title: parse_xml
parent: Processors
grand_parent: Pipelines
nav_order: 83
---

# parse_xml

The `parse_xml` processor parses XML data for an event.

## Configuration

You can configure the `parse_xml` processor with the following options.

| Option | Required | Type | Description |
| :--- | :--- | :--- | :--- |
| `source` | No | String | The field in the `event` that is parsed. Default value is `message`. |
lizsnyder marked this conversation as resolved.
Show resolved Hide resolved
| `destination` | No | String | The destination field of the parsed XML. Defaults to the root of the `event`. Cannot be `""`, `/`, or any white-space-only `string` because these are not valid `event` fields. |
lizsnyder marked this conversation as resolved.
Show resolved Hide resolved
| `pointer` | No | String | A JSON pointer to the field to be parsed. There is no `pointer` by default, meaning that the entire `source` is parsed. The `pointer` can access JSON array indexes as well. If the JSON pointer is invalid, then the entire `source` data is parsed into the outgoing `event`. If the key that is pointed to already exists in the `event` and the `destination` is the root, then the pointer uses the entire path of the key. |
lizsnyder marked this conversation as resolved.
Show resolved Hide resolved
| `tags_on_failure` | No | String | A list of strings that specify the tags to be set in the event that the processors fails or an unknown exception occurs while parsing.
lizsnyder marked this conversation as resolved.
Show resolved Hide resolved
lizsnyder marked this conversation as resolved.
Show resolved Hide resolved

## Usage

The following examples show how to use the `parse_xml` processor in your pipeline.

### Example: Minimum configuration

The following example shows the minimum configuration for the `parse_xml` processor:

```yaml
parse-xml-pipeline:
source:
stdin:
processor:
- parse_xml:
source: "my_xml"
sink:
- stdout:
```
{% include copy.html %}

When the input event contains the following data:

```
{ "my_xml": "<Person><name>John Doe</name><age>30</age></Person>" }
```

The processor parses the event into the following output:

```
{ "name": "John Doe", "age": "30" }
```
Loading