<?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 Join multiple fields from xml in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-multiple-fields-from-xml/m-p/419165#M120503</link>
    <description>&lt;P&gt;I want to join these different product_id's from an XML file into one table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;product_detail&amp;gt; 
  &amp;lt;product_id&amp;gt;1003C&amp;lt;/product_id&amp;gt;
&amp;lt;product_detail&amp;gt;
  &amp;lt;product_id&amp;gt;1002C&amp;lt;/product_id&amp;gt;
&amp;lt;/product_detail&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example: 1003C,1002C&lt;/P&gt;

&lt;P&gt;I've tried split, mvjoin, spath, and nothing works. Here's sample of my query:&lt;BR /&gt;
    source=xxxxxx.log&lt;BR /&gt;
    | xmlkv &lt;BR /&gt;
    | spath input=product_id&lt;BR /&gt;
    | table product_id&lt;BR /&gt;
    | eval product_id=split(product_id,";") &lt;BR /&gt;
    | eval product_id=mvjoin(product_id,";") &lt;/P&gt;

&lt;P&gt;How do I get the output of these multiple values into a semi-colon?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 19:41:46 GMT</pubDate>
    <dc:creator>roblr052</dc:creator>
    <dc:date>2020-09-29T19:41:46Z</dc:date>
    <item>
      <title>Join multiple fields from xml</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-multiple-fields-from-xml/m-p/419165#M120503</link>
      <description>&lt;P&gt;I want to join these different product_id's from an XML file into one table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;product_detail&amp;gt; 
  &amp;lt;product_id&amp;gt;1003C&amp;lt;/product_id&amp;gt;
&amp;lt;product_detail&amp;gt;
  &amp;lt;product_id&amp;gt;1002C&amp;lt;/product_id&amp;gt;
&amp;lt;/product_detail&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example: 1003C,1002C&lt;/P&gt;

&lt;P&gt;I've tried split, mvjoin, spath, and nothing works. Here's sample of my query:&lt;BR /&gt;
    source=xxxxxx.log&lt;BR /&gt;
    | xmlkv &lt;BR /&gt;
    | spath input=product_id&lt;BR /&gt;
    | table product_id&lt;BR /&gt;
    | eval product_id=split(product_id,";") &lt;BR /&gt;
    | eval product_id=mvjoin(product_id,";") &lt;/P&gt;

&lt;P&gt;How do I get the output of these multiple values into a semi-colon?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:41:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-multiple-fields-from-xml/m-p/419165#M120503</guid>
      <dc:creator>roblr052</dc:creator>
      <dc:date>2020-09-29T19:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Join multiple fields from xml</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-multiple-fields-from-xml/m-p/419166#M120504</link>
      <description>&lt;P&gt;@roblr052, your sample XML data seems incorrect. Your first &lt;CODE&gt;&amp;lt;product_detail&amp;gt;&lt;/CODE&gt; does not have an end node. I am not sure if that is how the data is or whether it was a type while posting the sample data here.&lt;/P&gt;

&lt;P&gt;Following is a run anywhere example with corrected sample data and &lt;CODE&gt;spath&lt;/CODE&gt; command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults
|  eval _raw="&amp;lt;data&amp;gt;
                 &amp;lt;product_detail&amp;gt; 
                    &amp;lt;product_id&amp;gt;1003C&amp;lt;/product_id&amp;gt;
                 &amp;lt;/product_detail&amp;gt;
                 &amp;lt;product_detail&amp;gt;
                    &amp;lt;product_id&amp;gt;1002C&amp;lt;/product_id&amp;gt;
                 &amp;lt;/product_detail&amp;gt;
              &amp;lt;/data&amp;gt;"
| spath
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm. &lt;/P&gt;

&lt;P&gt;If correct xml data is indexed, then either &lt;CODE&gt;KV_MODE=xml&lt;/CODE&gt; should be used to get xml fields extracted automatically during search time field discovery.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 19:05:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-multiple-fields-from-xml/m-p/419166#M120504</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-25T19:05:02Z</dc:date>
    </item>
  </channel>
</rss>

