Format XML to a Max Line Length
Format XML in @rawstring field using the xml:prettyPrint()
function with custom formatting parameters set
Query
formattedXml := xml:prettyPrint(field=payload, step=4, width=100)
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 with parameters to format the XML data in the
payload field to a max
line length of 100 and indent by 4 spaces.
Step-by-Step
Starting with the source repository events.
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0>Augment Data] result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
formattedXml := xml:prettyPrint(field=payload, step=4, width=100)
Uses the
field
parameter to specify the payload field as the source of XML data, thestep
parameter set to4
, and thewidth
parameter set to100
to format the XML data in the payload field to a max line length of 100 and indent by 4 spaces.The results are assigned to a new field named formattedXml.
Event Result set.
Summary and Results
The query is used to make XML data more readable in the results by defining a max line length of 100 and indent by 4 spaces.