<?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 Parsing XML log files in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Parsing-XML-log-files/m-p/362080#M66035</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I would to like to index a log in xml format and I would to like to parse it so that the content of each event was what was inside the tags, as shown below:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2863i6FC103536C0C2739/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Event1 = content 1&lt;BR /&gt;
Event2 = content 2&lt;/P&gt;

&lt;P&gt;How can I do this? Is there a regular expression for the above example?&lt;/P&gt;

&lt;P&gt;Best regards,&lt;BR /&gt;
Lopes.&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2017 20:58:12 GMT</pubDate>
    <dc:creator>monteirolopes</dc:creator>
    <dc:date>2017-05-03T20:58:12Z</dc:date>
    <item>
      <title>Parsing XML log files</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Parsing-XML-log-files/m-p/362080#M66035</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I would to like to index a log in xml format and I would to like to parse it so that the content of each event was what was inside the tags, as shown below:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2863i6FC103536C0C2739/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Event1 = content 1&lt;BR /&gt;
Event2 = content 2&lt;/P&gt;

&lt;P&gt;How can I do this? Is there a regular expression for the above example?&lt;/P&gt;

&lt;P&gt;Best regards,&lt;BR /&gt;
Lopes.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 20:58:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Parsing-XML-log-files/m-p/362080#M66035</guid>
      <dc:creator>monteirolopes</dc:creator>
      <dc:date>2017-05-03T20:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing XML log files</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Parsing-XML-log-files/m-p/362081#M66036</link>
      <description>&lt;P&gt;@monteirolopes... depends on how you are loading XML data. Is the entire content itself XML or is XML part of content with some additional text without XML format.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;For raw  XML event&lt;/STRONG&gt;&lt;BR /&gt;
Based on whether you want to have Splunk perform automatic XML extraction during index time or search time you can choose between either one of &lt;STRONG&gt;INDEXED_EXTRACTIONS&lt;/STRONG&gt; or &lt;STRONG&gt;KV_MODE&lt;/STRONG&gt; as &lt;STRONG&gt;XML&lt;/STRONG&gt;. Refer to the following documentation: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Data/Extractfieldsfromfileswithstructureddata#Props.conf_attributes_for_structured_data"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Data/Extractfieldsfromfileswithstructureddata#Props.conf_attributes_for_structured_data&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;For XML data as a subset of raw event&lt;/STRONG&gt;&lt;BR /&gt;
You can use &lt;STRONG&gt;spath&lt;/STRONG&gt; to traverse XML once you have extracted XML Data.&lt;/P&gt;

&lt;P&gt;Please find below run anywhere search for your mock data. Also refer to spath documentation: &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;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval mockXMLData="&amp;lt;Flow_data&amp;gt;Content1&amp;lt;/Flow_data&amp;gt;&amp;lt;Detected_signatures&amp;gt;Content2&amp;lt;/Detected_signatures&amp;gt;"
| spath input=mockXMLData path=Detected_signatures output=key
| table key mockXMLData
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: You can apply regular expression using &lt;STRONG&gt;rex&lt;/STRONG&gt;, command but spath has been written specifically for XML and JSON data parsing.&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 03:48:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Parsing-XML-log-files/m-p/362081#M66036</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-05-04T03:48:21Z</dc:date>
    </item>
  </channel>
</rss>

