<?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: Search the data from a xml based log file based on the condition in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494911#M99911</link>
    <description>&lt;P&gt;sorry, now I can't touch splunk.&lt;BR /&gt;
another way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=yourindex "&amp;lt;track-item-number&amp;gt;"
|rex "\&amp;lt;track-item-number\&amp;gt;(?&amp;lt;track_item_number&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;maybe works.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jan 2020 09:44:39 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-01-23T09:44:39Z</dc:date>
    <item>
      <title>Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494908#M99908</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am trying to search and display the data from a xml based log file with the matching condition.&lt;BR /&gt;
My XML is like below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;track-exception-code&amp;gt;70&amp;lt;/track-exception-code&amp;gt;
&amp;lt;track-item-number&amp;gt;779771138490&amp;lt;/track-item-number&amp;gt;
&amp;lt;track-location-code&amp;gt;COKED&amp;lt;/track-location-code&amp;gt;
&amp;lt;track-scan-time&amp;gt;0933&amp;lt;/track-scan-time&amp;gt;
&amp;lt;track-type&amp;gt;07&amp;lt;/track-type&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I used the below query to search for  the track-item-number&lt;/P&gt;

&lt;P&gt;host="" source="" |xpath outfield=track-item-number "//EnhancedEvent/master-list[track-type='07']/track-item-number"&lt;/P&gt;

&lt;P&gt;The result should display track-item-number as  779771138490 when i use the condition where track-type=07 and track-exception-code=70&lt;/P&gt;

&lt;P&gt;No results were displayed when i ran the above query. Could you please help me in this regard.&lt;/P&gt;

&lt;P&gt;Regard&lt;BR /&gt;
Rafi&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 07:28:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494908#M99908</guid>
      <dc:creator>rafimails</dc:creator>
      <dc:date>2020-01-23T07:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494909#M99909</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;....
| spath
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, how about this&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 09:00:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494909#M99909</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-23T09:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494910#M99910</link>
      <description>&lt;P&gt;can u give me the full query with spath?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 09:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494910#M99910</guid>
      <dc:creator>rafimails</dc:creator>
      <dc:date>2020-01-23T09:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494911#M99911</link>
      <description>&lt;P&gt;sorry, now I can't touch splunk.&lt;BR /&gt;
another way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=yourindex "&amp;lt;track-item-number&amp;gt;"
|rex "\&amp;lt;track-item-number\&amp;gt;(?&amp;lt;track_item_number&amp;gt;\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;maybe works.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 09:44:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494911#M99911</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-23T09:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494912#M99912</link>
      <description>&lt;P&gt;not working&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 10:06:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494912#M99912</guid>
      <dc:creator>rafimails</dc:creator>
      <dc:date>2020-01-23T10:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494913#M99913</link>
      <description>&lt;P&gt;index name can be any? if not where i can see the indexname&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 10:07:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494913#M99913</guid>
      <dc:creator>rafimails</dc:creator>
      <dc:date>2020-01-23T10:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494914#M99914</link>
      <description>&lt;P&gt;sorry, you can't try &lt;CODE&gt;spath&lt;/CODE&gt;?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time   track-exception-code    track-item-number   track-location-code track-scan-time track-type
2020/01/23 20:25:50 70  779771138490    COKED   0933    07
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The fields should be extracted neatly&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 11:28:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494914#M99914</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-23T11:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494915#M99915</link>
      <description>&lt;P&gt;can you give me the search string for the above result?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 11:34:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494915#M99915</guid>
      <dc:creator>rafimails</dc:creator>
      <dc:date>2020-01-23T11:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494916#M99916</link>
      <description>&lt;P&gt;This is how my xml looks like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;master-list&amp;gt;
&amp;lt;track-exception-code&amp;gt;70&amp;lt;/track-exception-code&amp;gt;
&amp;lt;track-item-number&amp;gt;779771138490&amp;lt;/track-item-number&amp;gt;
&amp;lt;track-location-code&amp;gt;COKED&amp;lt;/track-location-code&amp;gt;
&amp;lt;track-scan-time&amp;gt;0933&amp;lt;/track-scan-time&amp;gt;
&amp;lt;track-type&amp;gt;07&amp;lt;/track-type&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jan 2020 11:35:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494916#M99916</guid>
      <dc:creator>rafimails</dc:creator>
      <dc:date>2020-01-23T11:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494917#M99917</link>
      <description>&lt;P&gt;Please add your query below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jan 2020 12:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494917#M99917</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-23T12:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494918#M99918</link>
      <description>&lt;P&gt;@rafimails Sometimes using &lt;CODE&gt;xpath&lt;/CODE&gt; or &lt;CODE&gt;spath&lt;/CODE&gt; isn't what's best for readability or easiest. Sometimes it is. I've found using regular expressions is sometimes quite similar in performance and easier for readability, which is what I'll show you below in a run anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="&amp;lt;track-exception-code&amp;gt;70&amp;lt;/track-exception-code&amp;gt;,&amp;lt;track-item-number&amp;gt;779771138490&amp;lt;/track-item-number&amp;gt;,&amp;lt;track-location-code&amp;gt;COKED&amp;lt;/track-location-code&amp;gt;,&amp;lt;track-scan-time&amp;gt;0933&amp;lt;/track-scan-time&amp;gt;,&amp;lt;track-type&amp;gt;07&amp;lt;/track-type&amp;gt;"
| makemv _raw delim=","
| rex field=_raw "&amp;lt;track-exception-code&amp;gt;(?&amp;lt;track_exception_code&amp;gt;.+)&amp;lt;\/track-exception-code&amp;gt;"
| rex field=_raw "&amp;lt;track-item-number&amp;gt;(?&amp;lt;track_item_number&amp;gt;.+)&amp;lt;/track-item-number&amp;gt;"
| rex field=_raw "&amp;lt;track-location-code&amp;gt;(?&amp;lt;track_location_code&amp;gt;.+)&amp;lt;/track-location-code&amp;gt;"
| rex field=_raw "&amp;lt;track-scan-time&amp;gt;(?&amp;lt;track_scan_time&amp;gt;.+)&amp;lt;\/track-scan-time&amp;gt;"
| rex field=_raw "&amp;lt;track-type&amp;gt;(?&amp;lt;track_type&amp;gt;.+)&amp;lt;\/track-type&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now all your data is in fields that you can manipulate as you need. Cheers!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 13:46:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494918#M99918</guid>
      <dc:creator>efavreau</dc:creator>
      <dc:date>2020-01-23T13:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Search the data from a xml based log file based on the condition</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494919#M99919</link>
      <description>&lt;P&gt;this xml data in the logs are dynamic. I just want to search the data based on condition.  Exmaple my sample log file name is sample.log host is abc and in the sample log lets say track-type is 7 and track-exceiption-code is 74 and track-item-number is 12345&lt;BR /&gt;
I want to read this log file and display the track-item-number as 12345 when track-type=7 and track-exception-code is=74&lt;BR /&gt;
the root elements for the xml file is Enhancementevent and masterlist&lt;/P&gt;

&lt;P&gt;Sample xml file looks like below&lt;/P&gt;

&lt;P&gt;12345&lt;BR /&gt;
7&lt;BR /&gt;
74&lt;/P&gt;

&lt;P&gt;Search string:&lt;/P&gt;

&lt;P&gt;host=abc source= sample.log &lt;/P&gt;</description>
      <pubDate>Sun, 26 Jan 2020 07:04:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-the-data-from-a-xml-based-log-file-based-on-the-condition/m-p/494919#M99919</guid>
      <dc:creator>rafimails</dc:creator>
      <dc:date>2020-01-26T07:04:47Z</dc:date>
    </item>
  </channel>
</rss>

