<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to extract data from xml in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-extract-data-from-xml/m-p/25240#M970</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I want to extract data from the following xml ima using the xpath query to extract the data&lt;BR /&gt;
but its not able to fetch the data available in below tag please help&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;name&amp;gt;kk&amp;lt;name&amp;gt;
&amp;lt;data Name="ill" field="u"&amp;gt;uuuu&amp;lt;/data&amp;gt;
&amp;lt;data Name="jkl" field="op"&amp;gt;898989&amp;lt;/data&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to fetch 898989 from the following xml.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|xmlkv | xpath "//ev/reg/orig" outfield=data | table _time,name,data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;iam able to extract value of name but not from other two tag.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Aug 2012 13:47:32 GMT</pubDate>
    <dc:creator>john</dc:creator>
    <dc:date>2012-08-03T13:47:32Z</dc:date>
    <item>
      <title>How to extract data from xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-extract-data-from-xml/m-p/25240#M970</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I want to extract data from the following xml ima using the xpath query to extract the data&lt;BR /&gt;
but its not able to fetch the data available in below tag please help&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;name&amp;gt;kk&amp;lt;name&amp;gt;
&amp;lt;data Name="ill" field="u"&amp;gt;uuuu&amp;lt;/data&amp;gt;
&amp;lt;data Name="jkl" field="op"&amp;gt;898989&amp;lt;/data&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to fetch 898989 from the following xml.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|xmlkv | xpath "//ev/reg/orig" outfield=data | table _time,name,data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;iam able to extract value of name but not from other two tag.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2012 13:47:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-extract-data-from-xml/m-p/25240#M970</guid>
      <dc:creator>john</dc:creator>
      <dc:date>2012-08-03T13:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract data from xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-extract-data-from-xml/m-p/25241#M971</link>
      <description>&lt;P&gt;This may be outside of &lt;CODE&gt;xmlkv's&lt;/CODE&gt; abilities.  It is not based on a generalized XML parser and works best on schemas that are more like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;name&amp;gt;kk&amp;lt;/name&amp;gt;
&amp;lt;ill&amp;gt;uuuu&amp;lt;/ill&amp;gt;
&amp;lt;jkl&amp;gt;898989&amp;lt;/jkl&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If your schema is decently simple, you might be able to do this yourself with a rule in &lt;CODE&gt;transforms.conf&lt;/CODE&gt; similar to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[myxmltransform]
REGEX = &amp;lt;data Name="([^"]+)"[^&amp;gt;]+&amp;gt;([^&amp;lt;]+)&amp;lt;/data&amp;gt;
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this makes some fairly specific assumptions about the organization of your XML schema.  This is also not a true XML parsing operation, but simple pattern matching on the text.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Aug 2012 12:41:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-extract-data-from-xml/m-p/25241#M971</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2012-08-04T12:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract data from xml</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-extract-data-from-xml/m-p/25242#M972</link>
      <description>&lt;P&gt;&lt;CODE&gt;enter code here&lt;/CODE&gt;Use KV_MODE = XML in props.conf&lt;/P&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;P&gt;Check out the spath command.&lt;/P&gt;

&lt;P&gt;| spath&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;SPATH&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;The spath command--the "s" stands for Splunk (or structured) -- provides a straightforward means for extracting information from structured data formats, XML and JSON. It also highlights the syntax in the displayed events list.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;KV_MODE:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;KV_MODE = [none|auto|multi|json|xml]
* Used for search-time field extractions only.
* Specifies the field/value extraction mode for the data.
* Set KV_MODE to one of the following:
        * none: if you want no field/value extraction to take place.
        * auto: extracts field/value pairs separated by equal signs.
        * multi: invokes the multikv search command to expand a tabular event into multiple events.
    * xml : automatically extracts fields from XML data.
    * json: automatically extracts fields from JSON data.
* Setting to 'none' can ensure that one or more user-created regexes are not overridden by
  automatic field/value extraction for a particular host, source, or source type, and also
  increases search performance.
* Defaults to auto.
* The 'xml' and 'json' modes will not extract any fields when used on data that isn't of the correct format (JSON or XML).
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Aug 2012 16:07:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-extract-data-from-xml/m-p/25242#M972</guid>
      <dc:creator>dmaislin_splunk</dc:creator>
      <dc:date>2012-08-04T16:07:13Z</dc:date>
    </item>
  </channel>
</rss>

