<?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 How to return xml grouped by parent element? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-return-xml-grouped-by-parent-element/m-p/375908#M68078</link>
    <description>&lt;P&gt;I want to convert my _raw xml data in a query to a list of parent with an mv field of children.&lt;BR /&gt;
Lets say the structure looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;elements&amp;gt;
   &amp;lt;element&amp;gt;
     &amp;lt;name&amp;gt;element one&amp;lt;/name&amp;gt;
     &amp;lt;items&amp;gt;
         &amp;lt;item&amp;gt; 1   &amp;lt;/item&amp;gt;
         &amp;lt;item&amp;gt; 2   &amp;lt;/item&amp;gt;
         &amp;lt;item&amp;gt; 3   &amp;lt;/item&amp;gt;
     &amp;lt;/items&amp;gt;    
   &amp;lt;/element&amp;gt;

   &amp;lt;element&amp;gt;
     &amp;lt;name&amp;gt;element two&amp;lt;/name&amp;gt;
     &amp;lt;items&amp;gt;
         &amp;lt;item&amp;gt; 4   &amp;lt;/item&amp;gt;
         &amp;lt;item&amp;gt; 9   &amp;lt;/item&amp;gt;
     &amp;lt;/items&amp;gt;    
   &amp;lt;/element&amp;gt;
&amp;lt;/elements&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I try to get as a result is a table like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;element name                          items
--------------------------------------------------------------------------------
element one        |                 1
                   |                 2
                   |                 3
--------------------------------------------------------------------------------
element two        |                 4
                   |                 9
--------------------------------------------------------------------------------
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where items is a multi value field.&lt;BR /&gt;
I tried using spath this gives me a list of the elements, but I cant get the items to be grouped by the element name.&lt;BR /&gt;
Any help is welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 07 May 2018 14:18:48 GMT</pubDate>
    <dc:creator>sboogaar</dc:creator>
    <dc:date>2018-05-07T14:18:48Z</dc:date>
    <item>
      <title>How to return xml grouped by parent element?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-return-xml-grouped-by-parent-element/m-p/375908#M68078</link>
      <description>&lt;P&gt;I want to convert my _raw xml data in a query to a list of parent with an mv field of children.&lt;BR /&gt;
Lets say the structure looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;elements&amp;gt;
   &amp;lt;element&amp;gt;
     &amp;lt;name&amp;gt;element one&amp;lt;/name&amp;gt;
     &amp;lt;items&amp;gt;
         &amp;lt;item&amp;gt; 1   &amp;lt;/item&amp;gt;
         &amp;lt;item&amp;gt; 2   &amp;lt;/item&amp;gt;
         &amp;lt;item&amp;gt; 3   &amp;lt;/item&amp;gt;
     &amp;lt;/items&amp;gt;    
   &amp;lt;/element&amp;gt;

   &amp;lt;element&amp;gt;
     &amp;lt;name&amp;gt;element two&amp;lt;/name&amp;gt;
     &amp;lt;items&amp;gt;
         &amp;lt;item&amp;gt; 4   &amp;lt;/item&amp;gt;
         &amp;lt;item&amp;gt; 9   &amp;lt;/item&amp;gt;
     &amp;lt;/items&amp;gt;    
   &amp;lt;/element&amp;gt;
&amp;lt;/elements&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I try to get as a result is a table like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;element name                          items
--------------------------------------------------------------------------------
element one        |                 1
                   |                 2
                   |                 3
--------------------------------------------------------------------------------
element two        |                 4
                   |                 9
--------------------------------------------------------------------------------
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where items is a multi value field.&lt;BR /&gt;
I tried using spath this gives me a list of the elements, but I cant get the items to be grouped by the element name.&lt;BR /&gt;
Any help is welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 14:18:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-return-xml-grouped-by-parent-element/m-p/375908#M68078</guid>
      <dc:creator>sboogaar</dc:creator>
      <dc:date>2018-05-07T14:18:48Z</dc:date>
    </item>
  </channel>
</rss>

