Splunk Cloud Platform

Search Reference

Acrobat logo Download manual as PDF


Acrobat logo Download topic as PDF

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
PREVIOUS
x11
  NEXT
xmlunescape

This documentation applies to the following versions of Splunk Cloud Platform: 8.0.2006, 8.0.2007, 8.1.2009, 8.1.2012, 8.1.2011, 8.1.2101, 8.1.2103, 8.2.2104, 8.2.2105 (latest FedRAMP release), 8.2.2106, 8.2.2107, 8.2.2109


Was this documentation topic helpful?

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