parsexml
Parses the XML document into a set of complex objects.
Syntax
parsexml [field=TARGET_FIELD] [overlay=BOOL]
Optional Parameter
field=TARGET_FIELD
- Field to be parsed in the input data stream (default:
line
). overlay=BOOL
- Option to control data-overwrite (default:
f
).t
: Outputs both the parsed data and the original data.f
: Outputs the parsed data only.
Usage
Extract XML nodes that belong to the root XML element into the field.
- If the XML node contains only a text node, the command uses the element tag as the name of the field and assigns the text value of the text node to the value of the field.
- If the XML node has attributes, the command converts the name-value pair of each XML attribute to the key-value pair of the map, and converts the text value of the text node of the XML element to the value of the _text field.
For example, if you parse the XML in the form of <doc><id>sample</id></doc>
, the value of the sample
string is assigned to the id field.
If the form of XML is <doc><id>sample</id><name locale="en">Logpresso</name></doc>
, two key-value pairs of locale=en
and _text=Logpresso
are assigned to the name field like {"locale":"en","_text":"Logpresso"}
. You can easily extract fields from the map inside a complex object by combining the parsemap command.
json
"{line: '<doc><id>sample</id><name locale="en">Logpresso</name></doc>'}"
| parsexml
| parsemap field=name overlay=t