<?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: How to index a text file in the xml format? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366427#M166452</link>
    <description>&lt;P&gt;@niketnilay, &lt;/P&gt;

&lt;P&gt;The difference is these 3 tags &lt;STRONG&gt;&amp;lt; , " , &amp;amp;gt&lt;/STRONG&gt;; in the text file needs to be changed to &amp;lt; , "  ,&amp;gt; respectively&lt;/P&gt;

&lt;P&gt;If so then the file will be automatically converted to a xml file.... better?&lt;/P&gt;</description>
    <pubDate>Wed, 16 Aug 2017 10:13:05 GMT</pubDate>
    <dc:creator>madhanbaskar</dc:creator>
    <dc:date>2017-08-16T10:13:05Z</dc:date>
    <item>
      <title>How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366423#M166448</link>
      <description>&lt;P&gt;/getClientProfileV1Request&amp;gt;&amp;lt;/SOAP-ENV:Body&amp;gt;&amp;lt;/SOAP-ENV:Envelope&amp;gt;&amp;lt;/soap-env:Body&amp;gt;-- HTTP Header values -&amp;lt;tp:headers xsi:type="http:HttpRequestHeaders" xmlns:http="&lt;A href="http://www.bea.com/wli/sb/transports/http"&gt;http://www.bea.com/wli/sb/transports/http&lt;/A&gt;" xmlns:tp="&lt;A href="http://www.bea.com/wli/sb/transports"&gt;http://www.bea.com/wli/sb/transports&lt;/A&gt;" xmlns:xsi="&lt;A href="http://www.w3.org/2001/XMLSchema-instance&amp;quot;&amp;gt;&amp;lt;tp:user-header"&gt;http://www.w3.org/2001/XMLSchema-instance&amp;amp;quot;&amp;amp;gt;&amp;amp;lt;tp:user-header&lt;/A&gt; name="Authorization" value="Basic cHJvZmlsZXVzZXI6cHJvZmlsM3VzM3I="/&amp;gt;&amp;lt;tp:user-header name="EData" value="19=1.2,15=RS-Ro,16=Dn,13=getCtRequest,11=REQ,2=getes,10=3xbhkxv0p9,7=Assigned,6=PCK069,5=getAssignedRoles,4=com,9=roscha3c,8=UNKNOWN,1.2=APP10865:3xbhkxw1kw:3xbhkxxefh,1.1=APP09470::3xbhkxv28o"/&amp;gt;&amp;lt;tp:user-header name="Syste" value="RO"/&amp;gt;&amp;lt;http:Accept&amp;gt;application/xml&amp;lt;/http:Accept&amp;gt;&amp;lt;http:Content-Type&amp;gt;text/xml&amp;lt;/http:Content-Type&amp;gt;&amp;lt;/tp:headers&amp;gt;&lt;/P&gt;

&lt;P&gt;Above is the log in text format inside a text file. I need to index the same in my indexer in XML format itself. what would be the easy way to read the text file and convert it to an XML file so that I can view the logs in xml format in splunk GUI?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 08:12:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366423#M166448</guid>
      <dc:creator>madhanbaskar</dc:creator>
      <dc:date>2017-08-11T08:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366424#M166449</link>
      <description>&lt;P&gt;@madhanbaskar, you can either define &lt;CODE&gt;KV_MODE=xml&lt;/CODE&gt; in props.conf for your input for Splunk to perform field discovery for XML data.&lt;/P&gt;

&lt;P&gt;Other option would be to use spath to traverse the xml data once it is indexed. &lt;/P&gt;

&lt;P&gt;Refer to documentation: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Automatickey-valuefieldextractionsatsearch-time#Automatic_key-value_field_extraction_and_the_sequence_of_search_operations"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Automatickey-valuefieldextractionsatsearch-time#Automatic_key-value_field_extraction_and_the_sequence_of_search_operations&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 19:37:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366424#M166449</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-11T19:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366425#M166450</link>
      <description>&lt;P&gt;@niketnilay, Thanks&lt;/P&gt;

&lt;P&gt;Will the above really help?&lt;/P&gt;

&lt;P&gt;My problem is, in the client server the logs are stored in text format(.txt) but I need to forward that log to splunk server and index those logs in XML format(.xml).&lt;/P&gt;

&lt;P&gt;What would be the easy way to do that?&lt;/P&gt;

&lt;P&gt;I'm not sure of how the Spath or KV_mode help in this transformation case?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 06:46:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366425#M166450</guid>
      <dc:creator>madhanbaskar</dc:creator>
      <dc:date>2017-08-16T06:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366426#M166451</link>
      <description>&lt;P&gt;On a test machine or your local machine, you can take a sample log containing XML data and upload to Splunk (follow steps from the documentation: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchTutorial/GetthetutorialdataintoSplunk"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchTutorial/GetthetutorialdataintoSplunk&lt;/A&gt;)&lt;BR /&gt;
Once you are in Sourcetype screen, from Advanced settings you can add &lt;CODE&gt;KV_MODE=xml&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;One of the other things you can try out is upload the data as txt and just run&lt;CODE&gt;spath&lt;/CODE&gt; command to extract fields as you need. &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;. PS: if your file has content other XML you can use &lt;CODE&gt;rex&lt;/CODE&gt; command to extract xml data first, before applying spath. &lt;/P&gt;

&lt;P&gt;Does the text file contain only XML or does it contain XML between some text data as delimiters? Would you be able to post the content of a sample file after masking/anonymizing sensitive data?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 07:19:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366426#M166451</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-16T07:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366427#M166452</link>
      <description>&lt;P&gt;@niketnilay, &lt;/P&gt;

&lt;P&gt;The difference is these 3 tags &lt;STRONG&gt;&amp;lt; , " , &amp;amp;gt&lt;/STRONG&gt;; in the text file needs to be changed to &amp;lt; , "  ,&amp;gt; respectively&lt;/P&gt;

&lt;P&gt;If so then the file will be automatically converted to a xml file.... better?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 10:13:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366427#M166452</guid>
      <dc:creator>madhanbaskar</dc:creator>
      <dc:date>2017-08-16T10:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366428#M166453</link>
      <description>&lt;P&gt;Sorry I just noticed that you might not be interested in XML spath rather value containing within XML nodes as Key Value Pairs. Splunk would have been able to directly extract Key Value pairs. However, in this case I see value=key, rather than key=value. Splunk's default fields can not start with numbers, hence can not be all numbers also. Besides you have multiple fields with &lt;STRONG&gt;name&lt;/STRONG&gt;. Only first one will get extracted by default.&lt;/P&gt;

&lt;P&gt;So, in your case I would suggest to go with Regular Expression based Field Extraction:&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/ExtractfieldsinteractivelywithIFX"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/ExtractfieldsinteractivelywithIFX&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In the above sample data can you please let me know what are the fields you are interested in?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 10:44:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366428#M166453</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-16T10:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366429#M166454</link>
      <description>&lt;P&gt;A similar case I had recently at &lt;A href="https://answers.splunk.com/answers/559859/how-can-we-index-an-entire-xml-document-as-one-eve.html"&gt;How can we index an entire XML document as one event?&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 10:53:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366429#M166454</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2017-08-16T10:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366430#M166455</link>
      <description>&lt;P&gt;@niketnilay,&lt;/P&gt;

&lt;P&gt;si=&amp;amp; quot ;&lt;A href="http://www.w3.org/2001/XMLSchema-instance"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/A&gt; &amp;amp; quot;&amp;amp; gt ;&amp;amp; lt ;tp:headers&lt;/P&gt;

&lt;P&gt;In the above sample i need to change the &amp;amp; quot ; &amp;amp; gt; &amp;amp; lt ;&lt;/P&gt;

&lt;P&gt;to " , &amp;gt; , &amp;lt; respectively.&lt;/P&gt;

&lt;P&gt;That should help me &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 11:00:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366430#M166455</guid>
      <dc:creator>madhanbaskar</dc:creator>
      <dc:date>2017-08-16T11:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366431#M166456</link>
      <description>&lt;P&gt;Can you &lt;STRONG&gt;re-post XML or edit your question&lt;/STRONG&gt; with &lt;STRONG&gt;Code button (101010)&lt;/STRONG&gt; here on Splunk Answers so that special characters are not escaped?&lt;/P&gt;

&lt;P&gt;I think your original post does not have &lt;CODE&gt;&amp;lt; " and &amp;gt;&lt;/CODE&gt; characters, rather have &lt;CODE&gt;&amp;amp;lt;&lt;/CODE&gt;, &lt;CODE&gt;&amp;amp;quot;&lt;/CODE&gt;, &lt;CODE&gt;&amp;amp;gt;&lt;/CODE&gt;. Please confirm if this is correct.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 11:50:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366431#M166456</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-16T11:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366432#M166457</link>
      <description>&lt;P&gt;@niketnilay , Exactly!!&lt;/P&gt;

&lt;P&gt;You are right. The original post doesnt have &amp;lt; &amp;gt; " rather it has lt,quot,gt ....&lt;/P&gt;

&lt;P&gt;I need to know how to change that in splunk so that in the place of lt,quot and gt ,  &amp;lt; " &amp;gt;  will get replaced??&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 11:01:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366432#M166457</guid>
      <dc:creator>madhanbaskar</dc:creator>
      <dc:date>2017-08-17T11:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366433#M166458</link>
      <description>&lt;P&gt;Can you please try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval xml_data=replace(replace(replace(_raw,"&amp;amp;lt;","&amp;lt;"),"&amp;amp;gt;","&amp;gt;"),"&amp;amp;quot;","\"")
| table xml_data
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 11:50:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366433#M166458</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-17T11:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366434#M166459</link>
      <description>&lt;P&gt;@niketnilay , &lt;/P&gt;

&lt;P&gt;Thanks that actually helped &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 15:55:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366434#M166459</guid>
      <dc:creator>madhanbaskar</dc:creator>
      <dc:date>2017-08-17T15:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to index a text file in the xml format?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366435#M166460</link>
      <description>&lt;P&gt;@madhanbaskar, I have converted the comment to answer. Please accept to mark this as answered.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 16:19:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-index-a-text-file-in-the-xml-format/m-p/366435#M166460</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-17T16:19:30Z</dc:date>
    </item>
  </channel>
</rss>

