<?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 parse more complex xml files? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-parse-more-complex-xml-files/m-p/300457#M19091</link>
    <description>&lt;P&gt;I'm working with some configuration files I'd like splunk to monitor for changes, specifically Cisco Jabber on a Windows box. When I import this into my dev box (with KV_MODE=xml), it doesn't know what to do with the key value pair (I set the encoding, linemerge=true). &lt;/P&gt;

&lt;P&gt;Do I need to use regex to grab these fields? I was really hoping to just import them into splunk and have it create the name : value pair into fields. My absolute last resort would be using python to convert these to json for splunk (not ideal). &lt;/P&gt;

&lt;P&gt;Here is a snippet of the config file I'm trying to get splunk to recognize:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;Jabber&amp;gt;
 &amp;lt;userConfig name="somename" value="true"/&amp;gt;
 &amp;lt;userConfig name="stores" value="filename:24:filename2:76"/&amp;gt;
...
&amp;lt;/Jabber&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Jul 2017 20:54:19 GMT</pubDate>
    <dc:creator>JSkier</dc:creator>
    <dc:date>2017-07-10T20:54:19Z</dc:date>
    <item>
      <title>How to parse more complex xml files?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-parse-more-complex-xml-files/m-p/300457#M19091</link>
      <description>&lt;P&gt;I'm working with some configuration files I'd like splunk to monitor for changes, specifically Cisco Jabber on a Windows box. When I import this into my dev box (with KV_MODE=xml), it doesn't know what to do with the key value pair (I set the encoding, linemerge=true). &lt;/P&gt;

&lt;P&gt;Do I need to use regex to grab these fields? I was really hoping to just import them into splunk and have it create the name : value pair into fields. My absolute last resort would be using python to convert these to json for splunk (not ideal). &lt;/P&gt;

&lt;P&gt;Here is a snippet of the config file I'm trying to get splunk to recognize:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;Jabber&amp;gt;
 &amp;lt;userConfig name="somename" value="true"/&amp;gt;
 &amp;lt;userConfig name="stores" value="filename:24:filename2:76"/&amp;gt;
...
&amp;lt;/Jabber&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jul 2017 20:54:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-parse-more-complex-xml-files/m-p/300457#M19091</guid>
      <dc:creator>JSkier</dc:creator>
      <dc:date>2017-07-10T20:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse more complex xml files?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-parse-more-complex-xml-files/m-p/300458#M19092</link>
      <description>&lt;P&gt;As far as you have entire XML data extracted (field extraction or rex) you can use spath or xpath to extract the fields of your choice. Following is a run-anywhere search based on your sample data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval xmlData="
 &amp;lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&amp;gt;
 &amp;lt;Jabber&amp;gt;
  &amp;lt;userConfig name=\"somename\" value=\"true\"/&amp;gt;
  &amp;lt;userConfig name=\"stores\" value=\"filename:24:filename2:76\"/&amp;gt;
 &amp;lt;/Jabber&amp;gt;
"
| spath input=xmlData path=Jabber.userConfig{@name} output=names
| spath input=xmlData path=Jabber.userConfig{@value} output=values
| spath input=xmlData path=Jabber.userConfig{1}{@name} output=name1
| spath input=xmlData path=Jabber.userConfig{1}{@value} output=value1
| table names values name1 value1 xmlData
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Refer to spath documentation for details: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 04:50:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-parse-more-complex-xml-files/m-p/300458#M19092</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-11T04:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse more complex xml files?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-parse-more-complex-xml-files/m-p/300459#M19093</link>
      <description>&lt;P&gt;Thanks, that works great for the statistics tab, but the events view is still one big xml and fields aren't extracting at all. I'm going to try a few other settings to see if splunk will just recognize the KV pair. I suppose I could evaluate for conditions off of your solution, but that seems overly complex for what I'm trying to do. &lt;/P&gt;

&lt;P&gt;Here is what I used after the raw data search (works great for a table):&lt;BR /&gt;
    | spath path=Jabber.userConfig{@name} output=names | spath path=Jabber.userConfig{@value} output=values | table names values&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 14:02:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-parse-more-complex-xml-files/m-p/300459#M19093</guid>
      <dc:creator>JSkier</dc:creator>
      <dc:date>2017-07-11T14:02:53Z</dc:date>
    </item>
  </channel>
</rss>

