<?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 Re: xml field extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/xml-field-extraction/m-p/13209#M1184</link>
    <description>&lt;P&gt;This should do the trick:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;EXTRACT-emailsize = &amp;lt;email\s+size=["'](?&amp;lt;emailSize&amp;gt;\d)["'][&amp;gt; ]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Of course, if &lt;CODE&gt;size&lt;/CODE&gt; isn't always the first attribute in the &lt;CODE&gt;email&lt;/CODE&gt; element, then the regex can start to get ugly.&lt;/P&gt;

&lt;P&gt;If you are asking how you can automatically extract key value pairs using a combination of the element name and attribute name (like &lt;CODE&gt;emailSize&lt;/CODE&gt;, &lt;CODE&gt;headerName&lt;/CODE&gt;, &lt;CODE&gt;headerValue&lt;/CODE&gt;, &lt;CODE&gt;commandClass&lt;/CODE&gt;, &lt;CODE&gt;commandData&lt;/CODE&gt;, ... and so on), then it's not something splunk does out of the box...&lt;/P&gt;

&lt;P&gt;You may also find the &lt;CODE&gt;xmlkv&lt;/CODE&gt; command helpful.  The the search &lt;CODE&gt;source=*.xml | xmlkv&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 11 May 2010 02:44:20 GMT</pubDate>
    <dc:creator>Lowell</dc:creator>
    <dc:date>2010-05-11T02:44:20Z</dc:date>
    <item>
      <title>xml field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/xml-field-extraction/m-p/13208#M1183</link>
      <description>&lt;P&gt;could someone please explain what stanza configuration i should include in the props.conf file to extract the size attribute from &lt;CODE&gt;&amp;lt;email&amp;gt;&lt;/CODE&gt; into the field emailSize. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;stream TimeScanned="1271078550"&amp;gt;
&amp;lt;command class="MAIL FROM" data="&amp;amp;lt;me@gmail.com&amp;amp;gt; SIZE=42446" /&amp;gt;
&amp;lt;email size="42521"&amp;gt;
    &amp;lt;header Name="attachmentname" Value="driver-install.pdf" /&amp;gt;
    &amp;lt;/email&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;thanks,&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2010 00:15:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/xml-field-extraction/m-p/13208#M1183</guid>
      <dc:creator>carmackd</dc:creator>
      <dc:date>2010-05-11T00:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: xml field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/xml-field-extraction/m-p/13209#M1184</link>
      <description>&lt;P&gt;This should do the trick:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;EXTRACT-emailsize = &amp;lt;email\s+size=["'](?&amp;lt;emailSize&amp;gt;\d)["'][&amp;gt; ]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Of course, if &lt;CODE&gt;size&lt;/CODE&gt; isn't always the first attribute in the &lt;CODE&gt;email&lt;/CODE&gt; element, then the regex can start to get ugly.&lt;/P&gt;

&lt;P&gt;If you are asking how you can automatically extract key value pairs using a combination of the element name and attribute name (like &lt;CODE&gt;emailSize&lt;/CODE&gt;, &lt;CODE&gt;headerName&lt;/CODE&gt;, &lt;CODE&gt;headerValue&lt;/CODE&gt;, &lt;CODE&gt;commandClass&lt;/CODE&gt;, &lt;CODE&gt;commandData&lt;/CODE&gt;, ... and so on), then it's not something splunk does out of the box...&lt;/P&gt;

&lt;P&gt;You may also find the &lt;CODE&gt;xmlkv&lt;/CODE&gt; command helpful.  The the search &lt;CODE&gt;source=*.xml | xmlkv&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2010 02:44:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/xml-field-extraction/m-p/13209#M1184</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-05-11T02:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: xml field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/xml-field-extraction/m-p/13210#M1185</link>
      <description>&lt;P&gt;If the regexes just get too crazy one other option is to leave props.conf alone and just use the xpath command at search time: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | xpath "//email/@size" outfield=emailSize | search emailSize &amp;gt; 40000
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 May 2010 14:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/xml-field-extraction/m-p/13210#M1185</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-05-11T14:29:45Z</dc:date>
    </item>
  </channel>
</rss>

