From 7bbea74c8f689a0b38943063e10b8c27efa31b3f Mon Sep 17 00:00:00 2001 From: Liz Snyder <31932630+lizsnyder@users.noreply.github.com> Date: Tue, 2 Apr 2024 05:47:01 -0700 Subject: [PATCH] Add parse XML docs (#6822) * Add parse XML docs Signed-off-by: Liz Snyder <31932630+lizsnyder@users.noreply.github.com> * Add parse_when Signed-off-by: Liz Snyder <31932630+lizsnyder@users.noreply.github.com> * Update _data-prepper/pipelines/configuration/processors/parse-xml.md Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Signed-off-by: Liz Snyder <31932630+lizsnyder@users.noreply.github.com> * Update _data-prepper/pipelines/configuration/processors/parse-xml.md Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Signed-off-by: Liz Snyder <31932630+lizsnyder@users.noreply.github.com> * Tweaks Signed-off-by: Liz Snyder <31932630+lizsnyder@users.noreply.github.com> * Apply suggestions from code review Signed-off-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com> --------- Signed-off-by: Liz Snyder <31932630+lizsnyder@users.noreply.github.com> Signed-off-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com> Co-authored-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com> --- .../configuration/processors/parse-xml.md | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 _data-prepper/pipelines/configuration/processors/parse-xml.md diff --git a/_data-prepper/pipelines/configuration/processors/parse-xml.md b/_data-prepper/pipelines/configuration/processors/parse-xml.md new file mode 100644 index 0000000000..861705da2b --- /dev/null +++ b/_data-prepper/pipelines/configuration/processors/parse-xml.md @@ -0,0 +1,55 @@ +--- +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 | Specifies which `event` field to parse. | +| `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. | +| `pointer` | No | String | A JSON pointer to the field to be parsed. The value is null 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` object. If the key that is pointed to already exists in the `event` object and the `destination` is the root, then the pointer uses the entire path of the key. | +| `parse_when` | No | String | Specifies under what conditions the processor should perform parsing. Default is no condition. Accepts a Data Prepper expression string following the [Data Prepper Expression Syntax]({{site.url}}{{site.baseurl}}/data-prepper/pipelines/expression-syntax/). | +| `tags_on_failure` | No | String | A list of strings that specify the tags to be set if the processor fails or an unknown exception occurs while parsing. + +## 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": "John Doe30" } +``` + +The processor parses the event into the following output: + +``` +{ "name": "John Doe", "age": "30" } +``` \ No newline at end of file