Splunk Cloud Platform

Search Reference

xmlkv

Description

The xmlkv command automatically extracts key-value pairs from XML-formatted data.

For JSON-formatted data, use the spath command.

Syntax

The required syntax is in bold.

xmlkv
[<field>]
maxinputs=<int>

Required arguments

None.

Optional arguments

field
Syntax: <field>
Description: The field from which to extract the key and value pairs.
Default: The _raw field.
maxinputs
Syntax: maxinputs=<int>
Description: Sets the maximum number of events or search results that can be passed as inputs into the xmlkv command per invocation of the command. The xmlkv command is invoked repeatedly in increments according to the maxinputs argument until the search is complete and all of the results have been displayed. Do not change the value of maxinputs unless you know what you are doing.
Default: 50000

Usage

The xmlkv command is a distributable streaming command. See Command types.

Keys and values in XML elements

From the following XML, name is the key and Settlers of Catan is the value in the first element.

<game>
   <name>Settlers of Catan</name>
   <category>competitive</category>
</game>
<game>
   <name>Ticket to Ride</name>
   <category>competitive</category>
</game>

Examples

1. Automatically extract key-value pairs

Extract key-value pairs from XML tags in the _raw field. Processes a maximum of 50000 events.

... | xmlkv

2. Extract key-value pairs in a specific number of increments

Extract the key-value pairs from events or search results in increments of 10,000 per invocation of the xmlkv command until the search has finished and all of the results are displayed.

... | xmlkv maxinputs=10000

See also

Commands
extract
kvform
multikv
rex
spath
xpath
Last modified on 18 October, 2021
x11   xmlunescape

This documentation applies to the following versions of Splunk Cloud Platform: 8.2.2112, 8.2.2201, 8.2.2202, 8.2.2203, 9.0.2205, 9.0.2208, 9.0.2209, 9.0.2303, 9.0.2305, 9.1.2308, 9.1.2312, 9.2.2403, 9.2.2406 (latest FedRAMP release), 9.3.2408


Was this topic useful?







You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters