Format XML
Format XML in @rawstring field using the xml:prettyPrint()
function
Query
#type=SOAP
| account=123
| xml:prettyPrint()
Introduction
The xml:prettyPrint()
function can be used to format
an XML field for improved readability. When used without parameters,
xml:prettyPrint()
assumes, that the XML is in the
@rawstring field.
In this example, the xml:prettyPrint()
function is used to format the @rawstring
field.
Step-by-Step
Starting with the source repository events.
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1[/Filter/] 2>Augment Data] result{{Result Set}} repo --> 0 0 --> 1 1 --> 2 2 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
#type=SOAP
Filters for events with the
XML
type. - flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1[/Filter/] 2>Augment Data] result{{Result Set}} repo --> 0 0 --> 1 1 --> 2 2 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
| account=123
Filters for events related to account 123.
It is recommended to filter the event set as much as possible before using the
xml:prettyPrint()
function to prevent unnecessary formatting of discarded data. - flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[/Filter/] 1[/Filter/] 2>Augment Data] result{{Result Set}} repo --> 0 0 --> 1 1 --> 2 2 --> result style 2 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
| xml:prettyPrint()
Formats the
XML
content for improved readability. Without a specified field, it formats the @rawstring field.Note that if input is not valid XML, it returns unmodified values. To prevent this, you can set a
strict
parameter. For an example of usage, see Format Only Valid XML. Event Result set.
Summary and Results
The query is used to make XML data more readable in the results. Formatting XML in the @rawstring field after filtering the data is very important as it is a resource-intensive operation.