<?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 apply xmlkv for result of other query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280371#M190517</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Still confused by what you are trying to achieve. Take a look at this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count
| eval myxml = "
  &amp;lt;Head&amp;gt;
     &amp;lt;Doc&amp;gt;
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
     &amp;lt;/Doc&amp;gt;
     &amp;lt;Doc&amp;gt;
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
     &amp;lt;/Doc&amp;gt;
     &amp;lt;Doc&amp;gt;    
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
     &amp;lt;/Doc&amp;gt;
  &amp;lt;/Head&amp;gt;
"
| spath input=myxml path=Head.Doc.node output=data
| fields - myxml
| mvexpand data
| xmlkv data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;data
{data..}
{data..}
{data..}
{data..}
{data..} 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note you can use either "xmlkv data" or "spath input=data" depending on how your data looks like.&lt;/P&gt;

&lt;P&gt;Isn't that what you are trying to achieve?&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2016 20:05:05 GMT</pubDate>
    <dc:creator>javiergn</dc:creator>
    <dc:date>2016-02-12T20:05:05Z</dc:date>
    <item>
      <title>how to apply xmlkv for result of other query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280367#M190513</link>
      <description>&lt;P&gt;Hi, &lt;BR /&gt;
I have huge xml and i have written a query to break the xml.&lt;/P&gt;

&lt;P&gt;Let me explain with small example ( though i am doing this on a bigger file, i am showing this for understanding)&lt;/P&gt;

&lt;P&gt;My main xml:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Head&amp;gt;
    &amp;lt;Doc&amp;gt;
        &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
        &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
    &amp;lt;/Doc&amp;gt;
    &amp;lt;Doc&amp;gt;
        &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
        &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
    &amp;lt;/Doc&amp;gt;
    &amp;lt;Doc&amp;gt;   
        &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
    &amp;lt;/Doc&amp;gt;
&amp;lt;/Head&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have written query to get the xml nodes. Now the results will be like this.&lt;BR /&gt;
My query is like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = "&amp;lt;index&amp;gt;" | xmlkv | spath output=node path=&amp;lt;MY_XPATH&amp;gt; | mvexpand node |table node
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After that, results would look like below. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
&amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
&amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
&amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
&amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, How can i apply xmlkv to get the data out of the results above.? &lt;BR /&gt;
i do not want to apply it on actual xml, as it is huge and do not need all the data. &lt;/P&gt;

&lt;P&gt;Thank You,&lt;BR /&gt;
Regards, &lt;BR /&gt;
Srini.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 14:47:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280367#M190513</guid>
      <dc:creator>sdaruna</dc:creator>
      <dc:date>2016-02-12T14:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply xmlkv for result of other query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280368#M190514</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I don't have access to an instance of Splunk right now but would the following maybe work for you?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your query above
| spath input=node
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
J&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 16:00:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280368#M190514</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-12T16:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply xmlkv for result of other query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280369#M190515</link>
      <description>&lt;P&gt;Hi Javier, &lt;/P&gt;

&lt;P&gt;No that is not what i want. I want to apply xmlkv on the results of the search, so that i can get the data directly from the broken xml.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 16:34:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280369#M190515</guid>
      <dc:creator>sdaruna</dc:creator>
      <dc:date>2016-02-12T16:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply xmlkv for result of other query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280370#M190516</link>
      <description>&lt;P&gt;Well, does spath is not giving you the fields from the xml inside &lt;CODE&gt;node&lt;/CODE&gt; tags??&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 17:05:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280370#M190516</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-12T17:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply xmlkv for result of other query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280371#M190517</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Still confused by what you are trying to achieve. Take a look at this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count
| eval myxml = "
  &amp;lt;Head&amp;gt;
     &amp;lt;Doc&amp;gt;
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
     &amp;lt;/Doc&amp;gt;
     &amp;lt;Doc&amp;gt;
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
     &amp;lt;/Doc&amp;gt;
     &amp;lt;Doc&amp;gt;    
         &amp;lt;node&amp;gt;{data..}&amp;lt;/node&amp;gt;
     &amp;lt;/Doc&amp;gt;
  &amp;lt;/Head&amp;gt;
"
| spath input=myxml path=Head.Doc.node output=data
| fields - myxml
| mvexpand data
| xmlkv data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;data
{data..}
{data..}
{data..}
{data..}
{data..} 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note you can use either "xmlkv data" or "spath input=data" depending on how your data looks like.&lt;/P&gt;

&lt;P&gt;Isn't that what you are trying to achieve?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 20:05:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-apply-xmlkv-for-result-of-other-query/m-p/280371#M190517</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-12T20:05:05Z</dc:date>
    </item>
  </channel>
</rss>

