<?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 use xmlkv in field extraction to identify values in XML? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-xmlkv-in-field-extraction-to-identify-values-in-XML/m-p/464115#M130817</link>
    <description>&lt;P&gt;sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw=" PURCHASEDLINEHAUL DISPATCH    2020-05-21T17:22:55.000Z 
   &amp;lt;ns2:numberCode&amp;gt;923&amp;lt;/ns2:numberCode&amp;gt;
   &amp;lt;ns2:numberType&amp;gt;2&amp;lt;/ns2:numberType&amp;gt;    &amp;lt;/origin&amp;gt;    &amp;lt;destination&amp;gt;
   &amp;lt;ns2:numberCode&amp;gt;72&amp;lt;/ns2:numberCode&amp;gt;
   &amp;lt;ns2:numberType&amp;gt;2&amp;lt;/ns2:numberType&amp;gt;    &amp;lt;/destination&amp;gt;
 &amp;lt;purchasedCost&amp;gt;
   &amp;lt;purchasedCostTripSegment&amp;gt;
      &amp;lt;purchCostReference&amp;gt;1587040&amp;lt;/purchCostReference&amp;gt;
      &amp;lt;carrier&amp;gt;FXTR&amp;lt;/carrier&amp;gt;
      &amp;lt;vendorType&amp;gt;DRAY&amp;lt;/vendorType&amp;gt;
      &amp;lt;carrierTrailerType&amp;gt;PZ1&amp;lt;/carrierTrailerType&amp;gt;
      &amp;lt;origin&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;923&amp;lt;/ns2:numberCode&amp;gt;  
      &amp;lt;/origin&amp;gt;
      &amp;lt;destination&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4022&amp;lt;/ns2:numberCode&amp;gt; 
      &amp;lt;/destination&amp;gt;      
   &amp;lt;/purchasedCostTripSegment&amp;gt;
   &amp;lt;purchasedCostTripSegment&amp;gt;
      &amp;lt;purchCostReference&amp;gt;1587040&amp;lt;/purchCostReference&amp;gt;
      &amp;lt;carrier&amp;gt;BNSF&amp;lt;/carrier&amp;gt;
      &amp;lt;vendorType&amp;gt;RAIL&amp;lt;/vendorType&amp;gt;
      &amp;lt;carrierTrailerType&amp;gt;PZ1&amp;lt;/carrierTrailerType&amp;gt;
      &amp;lt;origin&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4022&amp;lt;/ns2:numberCode&amp;gt; 
      &amp;lt;/origin&amp;gt;
      &amp;lt;destination&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4040&amp;lt;/ns2:numberCode&amp;gt; 
      &amp;lt;/destination&amp;gt;
   &amp;lt;/purchasedCostTripSegment&amp;gt;
   &amp;lt;purchasedCostTripSegment&amp;gt;
      &amp;lt;purchCostReference&amp;gt;1587040&amp;lt;/purchCostReference&amp;gt;
      &amp;lt;carrier&amp;gt;NS&amp;lt;/carrier&amp;gt;
      &amp;lt;vendorType&amp;gt;RAIL&amp;lt;/vendorType&amp;gt;
      &amp;lt;carrierTrailerType&amp;gt;PZ1&amp;lt;/carrierTrailerType&amp;gt;
      &amp;lt;origin&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4061&amp;lt;/ns2:numberCode&amp;gt;
      &amp;lt;/origin&amp;gt;
      &amp;lt;destination&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4040&amp;lt;/ns2:numberCode&amp;gt;
      &amp;lt;/destination&amp;gt;     
   &amp;lt;/purchasedCostTripSegment&amp;gt;    &amp;lt;/purchasedCost&amp;gt;"
| multikv noheader=t 
| fields _raw
| xmlkv
| rex "(?&amp;lt;time&amp;gt;\d\S+Z)"
| stats list(*) as *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You have to think about the form of the output.&lt;/P&gt;</description>
    <pubDate>Fri, 22 May 2020 23:43:16 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-05-22T23:43:16Z</dc:date>
    <item>
      <title>How to use xmlkv in field extraction to identify values in XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-xmlkv-in-field-extraction-to-identify-values-in-XML/m-p/464114#M130816</link>
      <description>&lt;P&gt;I have a huge XML file with many tiers. I use this command to limit the number of events for the XML data that I want to extract, then I use xmlkv to extract the XML fields.  The fields that I need are extracted but not all of the data is pulled.&lt;/P&gt;

&lt;P&gt;This is the command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=83261 source="service.log" sourcetype="dispatchapp" "RULE" "createMessage MsgSource" | xmlkv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is a partial example of the XML file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;PURCHASEDLINEHAUL DISPATCH    2020-05-21T17:22:55.000Z 
  &amp;lt;ns2:numberCode&amp;gt;923&amp;lt;/ns2:numberCode&amp;gt;
  &amp;lt;ns2:numberType&amp;gt;2&amp;lt;/ns2:numberType&amp;gt;    &amp;lt;/origin&amp;gt;    &amp;lt;destination&amp;gt;
  &amp;lt;ns2:numberCode&amp;gt;72&amp;lt;/ns2:numberCode&amp;gt;
  &amp;lt;ns2:numberType&amp;gt;2&amp;lt;/ns2:numberType&amp;gt;    &amp;lt;/destination&amp;gt;
&amp;lt;purchasedCost&amp;gt;
  &amp;lt;purchasedCostTripSegment&amp;gt;
     &amp;lt;purchCostReference&amp;gt;1587040&amp;lt;/purchCostReference&amp;gt;
     &amp;lt;carrier&amp;gt;FXTR&amp;lt;/carrier&amp;gt;
     &amp;lt;vendorType&amp;gt;DRAY&amp;lt;/vendorType&amp;gt;
     &amp;lt;carrierTrailerType&amp;gt;PZ1&amp;lt;/carrierTrailerType&amp;gt;
     &amp;lt;origin&amp;gt;
        &amp;lt;ns2:numberCode&amp;gt;923&amp;lt;/ns2:numberCode&amp;gt;  

     &amp;lt;/origin&amp;gt;
     &amp;lt;destination&amp;gt;
        &amp;lt;ns2:numberCode&amp;gt;4022&amp;lt;/ns2:numberCode&amp;gt; 

     &amp;lt;/destination&amp;gt;      
  &amp;lt;/purchasedCostTripSegment&amp;gt;
  &amp;lt;purchasedCostTripSegment&amp;gt;
     &amp;lt;purchCostReference&amp;gt;1587040&amp;lt;/purchCostReference&amp;gt;
     &amp;lt;carrier&amp;gt;BNSF&amp;lt;/carrier&amp;gt;
     &amp;lt;vendorType&amp;gt;RAIL&amp;lt;/vendorType&amp;gt;
     &amp;lt;carrierTrailerType&amp;gt;PZ1&amp;lt;/carrierTrailerType&amp;gt;
     &amp;lt;origin&amp;gt;
        &amp;lt;ns2:numberCode&amp;gt;4022&amp;lt;/ns2:numberCode&amp;gt; 

     &amp;lt;/origin&amp;gt;
     &amp;lt;destination&amp;gt;
        &amp;lt;ns2:numberCode&amp;gt;4040&amp;lt;/ns2:numberCode&amp;gt; 

     &amp;lt;/destination&amp;gt;
  &amp;lt;/purchasedCostTripSegment&amp;gt;
  &amp;lt;purchasedCostTripSegment&amp;gt;
     &amp;lt;purchCostReference&amp;gt;1587040&amp;lt;/purchCostReference&amp;gt;
     &amp;lt;carrier&amp;gt;NS&amp;lt;/carrier&amp;gt;
     &amp;lt;vendorType&amp;gt;RAIL&amp;lt;/vendorType&amp;gt;
     &amp;lt;carrierTrailerType&amp;gt;PZ1&amp;lt;/carrierTrailerType&amp;gt;
     &amp;lt;origin&amp;gt;
        &amp;lt;ns2:numberCode&amp;gt;4061&amp;lt;/ns2:numberCode&amp;gt;
     &amp;lt;/origin&amp;gt;
     &amp;lt;destination&amp;gt;
        &amp;lt;ns2:numberCode&amp;gt;4040&amp;lt;/ns2:numberCode&amp;gt;
     &amp;lt;/destination&amp;gt;     
  &amp;lt;/purchasedCostTripSegment&amp;gt;    &amp;lt;/purchasedCost&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This image shows that the  &lt;CODE&gt;ns:numberCode&lt;/CODE&gt; is extracted buy only 3 but there are 5 instances in the view above. But the entire xml there are many more.&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/8983iFFA999D39EF040F1/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;How can I get the rest of the instances in the field extraction, and how can I identify the path where these values are coming from in the XML?&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 19:23:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-xmlkv-in-field-extraction-to-identify-values-in-XML/m-p/464114#M130816</guid>
      <dc:creator>3618475</dc:creator>
      <dc:date>2020-05-22T19:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to use xmlkv in field extraction to identify values in XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-xmlkv-in-field-extraction-to-identify-values-in-XML/m-p/464115#M130817</link>
      <description>&lt;P&gt;sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw=" PURCHASEDLINEHAUL DISPATCH    2020-05-21T17:22:55.000Z 
   &amp;lt;ns2:numberCode&amp;gt;923&amp;lt;/ns2:numberCode&amp;gt;
   &amp;lt;ns2:numberType&amp;gt;2&amp;lt;/ns2:numberType&amp;gt;    &amp;lt;/origin&amp;gt;    &amp;lt;destination&amp;gt;
   &amp;lt;ns2:numberCode&amp;gt;72&amp;lt;/ns2:numberCode&amp;gt;
   &amp;lt;ns2:numberType&amp;gt;2&amp;lt;/ns2:numberType&amp;gt;    &amp;lt;/destination&amp;gt;
 &amp;lt;purchasedCost&amp;gt;
   &amp;lt;purchasedCostTripSegment&amp;gt;
      &amp;lt;purchCostReference&amp;gt;1587040&amp;lt;/purchCostReference&amp;gt;
      &amp;lt;carrier&amp;gt;FXTR&amp;lt;/carrier&amp;gt;
      &amp;lt;vendorType&amp;gt;DRAY&amp;lt;/vendorType&amp;gt;
      &amp;lt;carrierTrailerType&amp;gt;PZ1&amp;lt;/carrierTrailerType&amp;gt;
      &amp;lt;origin&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;923&amp;lt;/ns2:numberCode&amp;gt;  
      &amp;lt;/origin&amp;gt;
      &amp;lt;destination&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4022&amp;lt;/ns2:numberCode&amp;gt; 
      &amp;lt;/destination&amp;gt;      
   &amp;lt;/purchasedCostTripSegment&amp;gt;
   &amp;lt;purchasedCostTripSegment&amp;gt;
      &amp;lt;purchCostReference&amp;gt;1587040&amp;lt;/purchCostReference&amp;gt;
      &amp;lt;carrier&amp;gt;BNSF&amp;lt;/carrier&amp;gt;
      &amp;lt;vendorType&amp;gt;RAIL&amp;lt;/vendorType&amp;gt;
      &amp;lt;carrierTrailerType&amp;gt;PZ1&amp;lt;/carrierTrailerType&amp;gt;
      &amp;lt;origin&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4022&amp;lt;/ns2:numberCode&amp;gt; 
      &amp;lt;/origin&amp;gt;
      &amp;lt;destination&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4040&amp;lt;/ns2:numberCode&amp;gt; 
      &amp;lt;/destination&amp;gt;
   &amp;lt;/purchasedCostTripSegment&amp;gt;
   &amp;lt;purchasedCostTripSegment&amp;gt;
      &amp;lt;purchCostReference&amp;gt;1587040&amp;lt;/purchCostReference&amp;gt;
      &amp;lt;carrier&amp;gt;NS&amp;lt;/carrier&amp;gt;
      &amp;lt;vendorType&amp;gt;RAIL&amp;lt;/vendorType&amp;gt;
      &amp;lt;carrierTrailerType&amp;gt;PZ1&amp;lt;/carrierTrailerType&amp;gt;
      &amp;lt;origin&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4061&amp;lt;/ns2:numberCode&amp;gt;
      &amp;lt;/origin&amp;gt;
      &amp;lt;destination&amp;gt;
         &amp;lt;ns2:numberCode&amp;gt;4040&amp;lt;/ns2:numberCode&amp;gt;
      &amp;lt;/destination&amp;gt;     
   &amp;lt;/purchasedCostTripSegment&amp;gt;    &amp;lt;/purchasedCost&amp;gt;"
| multikv noheader=t 
| fields _raw
| xmlkv
| rex "(?&amp;lt;time&amp;gt;\d\S+Z)"
| stats list(*) as *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You have to think about the form of the output.&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 23:43:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-xmlkv-in-field-extraction-to-identify-values-in-XML/m-p/464115#M130817</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-05-22T23:43:16Z</dc:date>
    </item>
  </channel>
</rss>

