<?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 Extract and addition of values from an XML log file in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-and-addition-of-values-from-an-XML-log-file/m-p/99790#M25743</link>
    <description>&lt;P&gt;Hi, I have been trying to extract valuesd from an XMl log file but failing so far.&lt;/P&gt;

&lt;P&gt;&lt;NUMBEROFSHEEP&gt;2&lt;NUMBEROFSHEEP&gt;&lt;BR /&gt;
&lt;NUMBEROFSHEEP&gt;3&lt;NUMBEROFSHEEP&gt;&lt;BR /&gt;
&lt;NUMBEROFSHEEP&gt;4&lt;NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/P&gt;

&lt;P&gt;This is the string I was using:&lt;BR /&gt;
Source = 'Sheep' | xmlkv count NumberOfSheep&lt;/P&gt;

&lt;P&gt;Could anyone please offer me some help,&lt;BR /&gt;
thanks for your help.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Apr 2013 16:11:23 GMT</pubDate>
    <dc:creator>a523504</dc:creator>
    <dc:date>2013-04-18T16:11:23Z</dc:date>
    <item>
      <title>Extract and addition of values from an XML log file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-and-addition-of-values-from-an-XML-log-file/m-p/99790#M25743</link>
      <description>&lt;P&gt;Hi, I have been trying to extract valuesd from an XMl log file but failing so far.&lt;/P&gt;

&lt;P&gt;&lt;NUMBEROFSHEEP&gt;2&lt;NUMBEROFSHEEP&gt;&lt;BR /&gt;
&lt;NUMBEROFSHEEP&gt;3&lt;NUMBEROFSHEEP&gt;&lt;BR /&gt;
&lt;NUMBEROFSHEEP&gt;4&lt;NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/NUMBEROFSHEEP&gt;&lt;/P&gt;

&lt;P&gt;This is the string I was using:&lt;BR /&gt;
Source = 'Sheep' | xmlkv count NumberOfSheep&lt;/P&gt;

&lt;P&gt;Could anyone please offer me some help,&lt;BR /&gt;
thanks for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2013 16:11:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-and-addition-of-values-from-an-XML-log-file/m-p/99790#M25743</guid>
      <dc:creator>a523504</dc:creator>
      <dc:date>2013-04-18T16:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Extract and addition of values from an XML log file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-and-addition-of-values-from-an-XML-log-file/m-p/99791#M25744</link>
      <description>&lt;P&gt;Your XML is malformed; the closing tags should be &lt;CODE&gt;&amp;lt;/numberofsheep&amp;gt;&lt;/CODE&gt; as such:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;numberofsheep&amp;gt;2&amp;lt;/numberofsheep&amp;gt;
&amp;lt;numberofsheep&amp;gt;3&amp;lt;/numberofsheep&amp;gt;
&amp;lt;numberofsheep&amp;gt;4&amp;lt;/numberofsheep&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you have that, you can use the xmlkv command (or the new &lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Spath"&gt;spath command)&lt;/A&gt; to extract the field:&lt;/P&gt;

&lt;P&gt;source = 'Sheep' | xmlkv&lt;/P&gt;

&lt;P&gt;...and then use stats to sum up the values:&lt;/P&gt;

&lt;P&gt;source = 'Sheep' | xmlkv | stats sum(numberofsheep)&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2013 19:57:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-and-addition-of-values-from-an-XML-log-file/m-p/99791#M25744</guid>
      <dc:creator>emechler_splunk</dc:creator>
      <dc:date>2013-04-18T19:57:38Z</dc:date>
    </item>
  </channel>
</rss>

