<?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 do you search with the xpath command in an XML file? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402220#M26375</link>
    <description>&lt;P&gt;Why not just use &lt;CODE&gt;spath&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval _raw="&amp;lt;tag1&amp;gt;&amp;lt;tag2 name=\"TEXTE\"&amp;gt;&amp;lt;tag3&amp;gt;TEXTE OF MESSAGE&amp;lt;/tag3&amp;gt;&amp;lt;/tag2&amp;gt;&amp;lt;/tag1&amp;gt;"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives you these:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_raw                                                                   _time                 tag1.tag2.tag3     tag1.tag2{@name}
&amp;lt;tag1&amp;gt;&amp;lt;tag2 name="TEXTE"&amp;gt;&amp;lt;tag3&amp;gt;TEXTE OF MESSAGE&amp;lt;/tag3&amp;gt;&amp;lt;/tag2&amp;gt;&amp;lt;/tag1&amp;gt;   2018-12-08 15:19:37   TEXTE OF MESSAGE   TEXTE
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Dec 2018 21:21:59 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2018-12-08T21:21:59Z</dc:date>
    <item>
      <title>How do you search with the xpath command in an XML file?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402216#M26371</link>
      <description>&lt;P&gt;I would like to extract the text of tag3 in xml file like that : &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/6149iFA3C1011D6C664EA/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;When i search the texte tag2 it's ok&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | xpath "//tag1/tag2/@name" output=name | chart count by name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What is the syntax of request to extract the text of tag3 ?&lt;/P&gt;

&lt;P&gt;None of those searches are OK&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | xpath "//tag1/tag2/tag3" output=text | chart count by text
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | xpath "//tag1/tag2/tag3" outfield=text | chart count by text
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 14:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402216#M26371</guid>
      <dc:creator>faribole</dc:creator>
      <dc:date>2018-11-23T14:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search with the xpath command in an XML file?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402217#M26372</link>
      <description>&lt;P&gt;Did you try using xmlkv in your search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; mysearch | xmlkv | chart count by name

you could also insert xmlkv as a search-time extraction on your search head props.conf 
[sourcetype]
KV_MODE = xml 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.2.1/SearchReference/Xmlkv"&gt;http://docs.splunk.com/Documentation/Splunk/7.2.1/SearchReference/Xmlkv&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 01:56:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402217#M26372</guid>
      <dc:creator>prakash007</dc:creator>
      <dc:date>2018-12-06T01:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search with the xpath command in an XML file?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402218#M26373</link>
      <description>&lt;P&gt;IF tag3 is fixed then you can try simple regex like-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|rex "&amp;lt;tag3&amp;gt;(?&amp;lt;TEXT&amp;gt;[^&amp;lt;]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 05:15:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402218#M26373</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-12-06T05:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search with the xpath command in an XML file?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402219#M26374</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;when i try this with my run everywhere example, everything works as expected. Maybe your xml is not correctly? For example the tags are not closed correctly? Also, the option is called outfield, not output.&lt;/P&gt;

&lt;P&gt;Here is the example, try your self:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="&amp;lt;tag1&amp;gt;&amp;lt;tag2 name=\"foo\"&amp;gt;&amp;lt;tag3&amp;gt;Test 123&amp;lt;/tag3&amp;gt;&amp;lt;/tag2&amp;gt;&amp;lt;/tag1&amp;gt;" | xpath "//tag1/tag2/tag3" outfield=value
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 15:51:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402219#M26374</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2018-12-06T15:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search with the xpath command in an XML file?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402220#M26375</link>
      <description>&lt;P&gt;Why not just use &lt;CODE&gt;spath&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval _raw="&amp;lt;tag1&amp;gt;&amp;lt;tag2 name=\"TEXTE\"&amp;gt;&amp;lt;tag3&amp;gt;TEXTE OF MESSAGE&amp;lt;/tag3&amp;gt;&amp;lt;/tag2&amp;gt;&amp;lt;/tag1&amp;gt;"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives you these:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_raw                                                                   _time                 tag1.tag2.tag3     tag1.tag2{@name}
&amp;lt;tag1&amp;gt;&amp;lt;tag2 name="TEXTE"&amp;gt;&amp;lt;tag3&amp;gt;TEXTE OF MESSAGE&amp;lt;/tag3&amp;gt;&amp;lt;/tag2&amp;gt;&amp;lt;/tag1&amp;gt;   2018-12-08 15:19:37   TEXTE OF MESSAGE   TEXTE
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Dec 2018 21:21:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-search-with-the-xpath-command-in-an-XML-file/m-p/402220#M26375</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-12-08T21:21:59Z</dc:date>
    </item>
  </channel>
</rss>

