<?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: parse XML embedded in a field in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/parse-XML-embedded-in-a-field/m-p/339985#M22086</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I have a CSV file with 2 fields : time,xml_data&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;As long as you know the name of the field in the CSV which contains the XML spath will work at seach time&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search which includes your csv events&amp;gt;| spath xml_data
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Dec 2017 14:20:33 GMT</pubDate>
    <dc:creator>nickhills</dc:creator>
    <dc:date>2017-12-14T14:20:33Z</dc:date>
    <item>
      <title>parse XML embedded in a field</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/parse-XML-embedded-in-a-field/m-p/339982#M22083</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;

&lt;P&gt;I have a CSV file with 2 fields : time,xml_data.&lt;BR /&gt;
Is there anyway I can parse the xml_data field as XML ?&lt;/P&gt;

&lt;P&gt;This is a nested XML inside a CSV field and I would prefer to parse it on index time (if not, parsing on search time is also acceptable).&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:14:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/parse-XML-embedded-in-a-field/m-p/339982#M22083</guid>
      <dc:creator>moneybox</dc:creator>
      <dc:date>2020-09-29T17:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: parse XML embedded in a field</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/parse-XML-embedded-in-a-field/m-p/339983#M22084</link>
      <description>&lt;P&gt;Hi @moneybox,&lt;/P&gt;

&lt;P&gt;You can use &lt;CODE&gt;spath&lt;/CODE&gt; for same. Check below search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup mylookup
| eval _raw=XML_DATA_FIELD 
| spath output=.. path=..
| table ..
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please check my sample search from below doc&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Spath"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval A="&amp;lt;?xml version=\"1.0\"&amp;gt;
&amp;lt;purchases&amp;gt;
   &amp;lt;book&amp;gt;
         &amp;lt;author&amp;gt;Martin, George R.R.&amp;lt;/author&amp;gt;
         &amp;lt;title yearPublished=1996&amp;gt;A Game of Thrones&amp;lt;/title&amp;gt;
         &amp;lt;title yearPublished=1998&amp;gt;A Clash of Kings&amp;lt;/title&amp;gt;
  &amp;lt;/book&amp;gt;
   &amp;lt;book&amp;gt;
         &amp;lt;author&amp;gt;Clarke, Susanna&amp;lt;/author&amp;gt;
         &amp;lt;title yearPublished=2004&amp;gt;Jonathan Strange and Mr. Norrell&amp;lt;/title&amp;gt;
   &amp;lt;/book&amp;gt;
   &amp;lt;book&amp;gt;
         &amp;lt;author&amp;gt;Kay, Guy Gavriel&amp;lt;/author&amp;gt;
         &amp;lt;title yearPublished=1990&amp;gt;Tigana&amp;lt;/title&amp;gt;
   &amp;lt;/book&amp;gt;
   &amp;lt;book&amp;gt;
         &amp;lt;author&amp;gt;Bujold, Lois McMasters&amp;lt;/author&amp;gt;
         &amp;lt;title yearPublished=1986&amp;gt;The Warrior's Apprentice&amp;lt;/title&amp;gt;
   &amp;lt;/book&amp;gt;
&amp;lt;/purchases&amp;gt;" 
| eval _raw=A 
| spath output=dates path=purchases.book.title{@yearPublished} 
| table dates
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 09:51:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/parse-XML-embedded-in-a-field/m-p/339983#M22084</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-12-14T09:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: parse XML embedded in a field</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/parse-XML-embedded-in-a-field/m-p/339984#M22085</link>
      <description>&lt;P&gt;Thank you, but that works for cases I know what fields should I expect.&lt;BR /&gt;
Is there anything that could automatically convert the nested XML to searchable fields in Index Time ?&lt;BR /&gt;
Meaning, I want to extract all fields from the nested XML without knowing them.&lt;/P&gt;

&lt;P&gt;Thanks again &lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 11:46:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/parse-XML-embedded-in-a-field/m-p/339984#M22085</guid>
      <dc:creator>moneybox</dc:creator>
      <dc:date>2017-12-14T11:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: parse XML embedded in a field</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/parse-XML-embedded-in-a-field/m-p/339985#M22086</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I have a CSV file with 2 fields : time,xml_data&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;As long as you know the name of the field in the CSV which contains the XML spath will work at seach time&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search which includes your csv events&amp;gt;| spath xml_data
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Dec 2017 14:20:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/parse-XML-embedded-in-a-field/m-p/339985#M22086</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2017-12-14T14:20:33Z</dc:date>
    </item>
  </channel>
</rss>

