XML
Available in AxoSyslog 4.13 and later.
Formats a dictionary into XML. To format data as Windows Event Log XML, see Windows Event Logs XML.
Usage: format_xml({"key1":{"nestedkey":"value"}})
The output XML for the previous example will be: <key><nestedkey>value</nestedkey></key>
Note the following points:
-
Store attributions in
@attrkey-value pairs.JSON: {"foo": {"@bar": "123", "@baz": "bad"}} XML: <foo bar="123" baz="bad"/> -
If an XML element has both attributes and a value, store text value under the
#textkey.JSON: {"foo": {"@bar": "123", "#text": "baz"}} XML: <foo bar="123">baz</foo> -
An XML element can have both a value and inner elements. We use the
#textkey here, too.JSON: {"foo": {"#text": "bar", "baz": "123"}} XML: <foo>bar<baz>123</baz></foo> -
JSON lists become values of separate tags:
JSON: {"a":{"b":["c","d"]}} XML: <a><b>c</b><b>d</b></a>You can add attributions for specific elements of such lists:
JSON: {"a":{"b":["c",{"@attr":"attr_val","#text":"e"}]}} XML: <a><b>c</b><b attr='attr_val'>e</b></a> -
A top-level JSON lists becomes a multi-root XML:
JSON: {"a":["b","c"]} XML: <a>b</a><a>c</a> -
Numeric values become text:
JSON: {"a":100} XML: <a>100</a> -
Empty elements are represented as short-format XML tags:
JSON: {"a":""} XML: <a/>