<?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 keep multiple events in one XML file but pull the key-value pairs from each transaction line? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132520#M7850</link>
    <description>&lt;P&gt;Doing that with XML is a bit annoying... with JSON you can apply spath partially, mvexpand, and apply the second half of spath then. Here you can do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | spath | eval temp = mvzip(Description, Qty) | mvexpand temp | rex field=temp "(?&amp;lt;Description&amp;gt;[^,]+),(?&amp;lt;Qty&amp;gt;[^,]+)" | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That's assuming the description doesn't contain a comma.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Nov 2014 00:27:17 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-11-25T00:27:17Z</dc:date>
    <item>
      <title>How to keep multiple events in one XML file but pull the key-value pairs from each transaction line?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132517#M7847</link>
      <description>&lt;P&gt;I have thousands of XML files which are being indexed in Splunk and I would like to extract values from the XML.   The XML data contains product information and transactions every time a sale occurs.   However, when I used xmlkv to extract the values from the XML, if there are multiple transactions, Splunk only sees the last key-value pair and disregards that multiple items were in the bucket/shopping cart.   I've played with xmlsplit and reviewed the documents regarding splitting the XML file in the props.conf, however then each event would lose valuable information like the timestamp and location which isn't stored in each transactionline.   An example of the data is below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;JournalHeader&amp;gt;
&amp;lt;/JournalHeader&amp;gt;
&amp;lt;SaleEvent&amp;gt;
  &amp;lt;TransactionDetailGroup&amp;gt;
    &amp;lt;TransactionLine status="normal"&amp;gt;
      &amp;lt;ItemLine&amp;gt;
        &amp;lt;ItemCode&amp;gt;
          &amp;lt;POSCode&amp;gt;1001&amp;lt;/POSCode&amp;gt;
        &amp;lt;/ItemCode&amp;gt;
        &amp;lt;Description&amp;gt;Product A&amp;lt;/Description&amp;gt;
      &amp;lt;/ItemLine&amp;gt;
    &amp;lt;/TransactionLine&amp;gt;
    &amp;lt;TransactionLine status="normal"&amp;gt;
      &amp;lt;ItemLine&amp;gt;
        &amp;lt;ItemCode&amp;gt;
          &amp;lt;POSCode&amp;gt;1011&amp;lt;/POSCode&amp;gt;
        &amp;lt;/ItemCode&amp;gt;
        &amp;lt;Description&amp;gt;Product B&amp;lt;/Description&amp;gt;
      &amp;lt;/ItemLine&amp;gt;
    &amp;lt;/TransactionLine&amp;gt;
    &amp;lt;TransactionLine status="normal"&amp;gt;
      &amp;lt;ItemLine&amp;gt;
        &amp;lt;ItemCode&amp;gt;
          &amp;lt;POSCode&amp;gt;1021&amp;lt;/POSCode&amp;gt;
        &amp;lt;/ItemCode&amp;gt;
        &amp;lt;Description&amp;gt;Product C&amp;lt;/Description&amp;gt;
      &amp;lt;/ItemLine&amp;gt;
    &amp;lt;/TransactionLine&amp;gt;
    &amp;lt;TransactionLine status="normal"&amp;gt;
    ...
    &amp;lt;/TransactionLine&amp;gt;
  &amp;lt;/TransactionDetailGroup&amp;gt;
  &amp;lt;TransactionSummary&amp;gt;
...
  &amp;lt;/TransactionSummary&amp;gt;
&amp;lt;/SaleEvent&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I do a table of 100 events and list the POSCode and Description, I would get 100 events with either 1001 &amp;amp; Product A or 1021 &amp;amp; Product C.&lt;/P&gt;

&lt;P&gt;Is there a way to keep the event as a single event but drill down into each TransactionLine and pull the key-values from each?&lt;/P&gt;</description>
      <pubDate>Sun, 23 Nov 2014 00:30:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132517#M7847</guid>
      <dc:creator>thesba</dc:creator>
      <dc:date>2014-11-23T00:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep multiple events in one XML file but pull the key-value pairs from each transaction line?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132518#M7848</link>
      <description>&lt;P&gt;Try using &lt;CODE&gt;spath&lt;/CODE&gt;: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/spath"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/spath&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | spath
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 Nov 2014 11:52:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132518#M7848</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-11-23T11:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep multiple events in one XML file but pull the key-value pairs from each transaction line?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132519#M7849</link>
      <description>&lt;P&gt;spath is helpful, thank you!.   What I'm trying to do is calculate sums on the purchased quantity and product.   With spath the fields have values of &lt;/P&gt;

&lt;P&gt;Qty &lt;BR /&gt;
1&lt;BR /&gt;
2&lt;BR /&gt;
1 &lt;/P&gt;

&lt;P&gt;Description&lt;BR /&gt;
Product A&lt;BR /&gt;
Product B&lt;BR /&gt;
Product C&lt;/P&gt;

&lt;P&gt;How would I associate &lt;BR /&gt;
Product A, Qty 1&lt;BR /&gt;
Product B, Qty 2&lt;BR /&gt;
Product C, Qty 1&lt;/P&gt;

&lt;P&gt;So I could do a search on all events and determine total products sold during different time periods?  I've tried using mvjoin and eval?  &lt;/P&gt;</description>
      <pubDate>Mon, 24 Nov 2014 04:56:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132519#M7849</guid>
      <dc:creator>thesba</dc:creator>
      <dc:date>2014-11-24T04:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep multiple events in one XML file but pull the key-value pairs from each transaction line?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132520#M7850</link>
      <description>&lt;P&gt;Doing that with XML is a bit annoying... with JSON you can apply spath partially, mvexpand, and apply the second half of spath then. Here you can do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | spath | eval temp = mvzip(Description, Qty) | mvexpand temp | rex field=temp "(?&amp;lt;Description&amp;gt;[^,]+),(?&amp;lt;Qty&amp;gt;[^,]+)" | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That's assuming the description doesn't contain a comma.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2014 00:27:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132520#M7850</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-11-25T00:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep multiple events in one XML file but pull the key-value pairs from each transaction line?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132521#M7851</link>
      <description>&lt;P&gt;So @thesba finally what is the solution you undertake?&lt;BR /&gt;
Can you share the approach, I am also trying to parse through POS XML log files.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2015 22:47:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-keep-multiple-events-in-one-XML-file-but-pull-the-key/m-p/132521#M7851</guid>
      <dc:creator>jensonthottian</dc:creator>
      <dc:date>2015-04-26T22:47:25Z</dc:date>
    </item>
  </channel>
</rss>

