<?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 extract Title from this XML data in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673945#M230716</link>
    <description>&lt;P&gt;I like this answer, unfortunately I am going to have to update the props for this since as it is not being recognized as a valid xml object and therefore doesn't work. Thanks for the assistance, I greatly appreciate you help!&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2024 14:25:11 GMT</pubDate>
    <dc:creator>tkwaller1</dc:creator>
    <dc:date>2024-01-11T14:25:11Z</dc:date>
    <item>
      <title>How to extract Title from this XML data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673791#M230688</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have a very long xml record that I am trying to spath some data from but I cant seem to get it to work. Can someone possibly give me some assistance?&lt;BR /&gt;Here's what the record looks like(sorry its SUPER long)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;2024-01-08 12:09:43.000, LOAD_DATE="2024-01-08 12:09:43.0", EVENT_LENGTH="14912", ID="3f29f958-af6e-4050-919e-fb23fc27e2bc", MSG_src="PXXXX", MSG_DOMAIN="APP", MSG_TYPE="INBOUND", MSG_DATA="&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;
&amp;lt;Message&amp;gt;
  &amp;lt;header&amp;gt;
    &amp;lt;domain&amp;gt;APP&amp;lt;/domain&amp;gt;
    &amp;lt;source&amp;gt;PXXXX&amp;lt;/source&amp;gt;
    &amp;lt;messageType&amp;gt;INBOUND&amp;lt;/messageType&amp;gt;
    &amp;lt;eventId&amp;gt;f8y6jk45-af6e-4050-919e-fb23fc27e2bc&amp;lt;/eventId&amp;gt;
  &amp;lt;/header&amp;gt;
  &amp;lt;parsing&amp;gt;
    &amp;lt;parsingStatus&amp;gt;SUCCESS&amp;lt;/parsingStatus&amp;gt;
    &amp;lt;parsingStatusDesc&amp;gt;Success&amp;lt;/parsingStatusDesc&amp;gt;
    &amp;lt;formType&amp;gt;1234&amp;lt;/formType&amp;gt;
  &amp;lt;/parsing&amp;gt;
  &amp;lt;ABC&amp;gt;
    &amp;lt;Code&amp;gt;ABC&amp;lt;/Code&amp;gt;
    &amp;lt;Number&amp;gt;209819&amp;lt;/Number&amp;gt;
    &amp;lt;sequence&amp;gt;0236&amp;lt;/sequence&amp;gt;
    &amp;lt;ReceiptDate&amp;gt;2024-01-08T00:00:00.000-05:00&amp;lt;/ReceiptDate&amp;gt;
    &amp;lt;FirstDate&amp;gt;2024-01-08T00:00:00.000-05:00&amp;lt;/FirstDate&amp;gt;
    &amp;lt;Status&amp;gt;SUCCESS&amp;lt;/Status&amp;gt;
    &amp;lt;location&amp;gt;xxxxxxxx&amp;lt;/location&amp;gt;
    &amp;lt;id&amp;gt;ci1704729189245.431902@fdsahl86ceb40c&amp;lt;/id&amp;gt;
    &amp;lt;format&amp;gt;ABCD&amp;lt;/format&amp;gt;
  &amp;lt;/ABC&amp;gt;
  &amp;lt;applicationDetails&amp;gt;
    &amp;lt;applicationGlobalId&amp;gt;500168938&amp;lt;/applicationGlobalId&amp;gt;
    &amp;lt;applicationType&amp;gt;ABC&amp;lt;/applicationType&amp;gt;
    &amp;lt;applicationSubtype&amp;gt;UNKNOWN&amp;lt;/applicationSubtype&amp;gt;
    &amp;lt;applicationNumber&amp;gt;123456&amp;lt;/applicationNumber&amp;gt;
    &amp;lt;applicationRelationships&amp;gt;
      &amp;lt;applicationRelationship&amp;gt;
        &amp;lt;ReasonCode&amp;gt;XYZ&amp;lt;/ReasonCode&amp;gt; 
		&amp;lt;Desc&amp;gt;BLAH BLAH BLAH&amp;lt;/Desc&amp;gt;
        &amp;lt;applicationGlobalId&amp;gt;123456789&amp;lt;/applicationGlobalId&amp;gt;
        &amp;lt;applicationNumber&amp;gt;123456&amp;lt;/applicationNumber&amp;gt;
        &amp;lt;applicationSubtype&amp;gt;UNKNOWN&amp;lt;/applicationSubtype&amp;gt;
        &amp;lt;applicationType&amp;gt;RED&amp;lt;/applicationType&amp;gt;
      &amp;lt;/applicationRelationship&amp;gt;
    &amp;lt;/applicationRelationships&amp;gt;
    &amp;lt;applicationPatents/&amp;gt;
    &amp;lt;applicationStatuses&amp;gt;
      &amp;lt;applicationStatus&amp;gt;
        &amp;lt;statusCode&amp;gt;APPROVED&amp;lt;/statusCode&amp;gt;
        &amp;lt;statusDescription&amp;gt;APPROVED&amp;lt;/statusDescription&amp;gt;
        &amp;lt;statusStartDate&amp;gt;2017-11-30T00:00:00.000-05:00&amp;lt;/statusStartDate&amp;gt;
      &amp;lt;/applicationStatus&amp;gt;
    &amp;lt;/applicationStatuses&amp;gt;
    &amp;lt;applicationProperties/&amp;gt;
  &amp;lt;/applicationDetails&amp;gt;
  &amp;lt;InboundDetails&amp;gt;
    &amp;lt;InboundType&amp;gt;Reply&amp;lt;/InboundType&amp;gt;
    &amp;lt;InboundSubtype&amp;gt;Reply2&amp;lt;/InboundSubtype&amp;gt;
    &amp;lt;InboundSequenceNumber&amp;gt;0236&amp;lt;/InboundSequenceNumber&amp;gt;
  &amp;lt;/InboundDetails&amp;gt;
  &amp;lt;form&amp;gt;
    &amp;lt;attributes&amp;gt;123-4560910-0001"/&amp;gt;
      &amp;lt;attribute description="EXPIRATION DATE" name="Expiration Date" value="03/31/2024"/&amp;gt;
      &amp;lt;attribute description="name" name="name_holder" value="Place Inc."/&amp;gt;
      &amp;lt;attribute description="NUMBER" name="number" value="209819"/&amp;gt;
      &amp;lt;attribute description="Bunch of strings" name="Desc"/&amp;gt;
    &amp;lt;/attributes&amp;gt;
    &amp;lt;List&amp;gt;
      &amp;lt;items/&amp;gt;
    &amp;lt;/List&amp;gt;
    &amp;lt;infoList&amp;gt;
      &amp;lt;info&amp;gt;
        &amp;lt;Type&amp;gt;Information goes here&amp;lt;/Type&amp;gt;
        &amp;lt;name&amp;gt;Me Formal&amp;lt;/name&amp;gt;
        &amp;lt;phoneNumber&amp;gt;+1 (111) 222-333&amp;lt;/phoneNumber&amp;gt;
        &amp;lt;addressLine1&amp;gt;1234 Road Drive&amp;lt;/addressLine1&amp;gt;
        &amp;lt;city&amp;gt;Place, MO&amp;lt;/city&amp;gt;
        &amp;lt;zipCode&amp;gt;12345&amp;lt;/zipCode&amp;gt;
        &amp;lt;emailAddress&amp;gt;me.formal@domain.com&amp;lt;/emailAddress&amp;gt;
        &amp;lt;partyContacts&amp;gt;
          &amp;lt;partyContact&amp;gt;
			&amp;lt;Date&amp;gt;2024-01-04T00:00:00.000-05:00&amp;lt;/Date&amp;gt;
            &amp;lt;state&amp;gt;MO&amp;lt;/state&amp;gt;
            &amp;lt;emailAddress&amp;gt;me.formal@domain.com&amp;lt;/emailAddress&amp;gt;
            &amp;lt;addressLine1&amp;gt;1234 Road Drive&amp;lt;/addressLine1&amp;gt;
            &amp;lt;city&amp;gt;Place&amp;lt;/city&amp;gt;
            &amp;lt;country&amp;gt;UNITED STATES&amp;lt;/country&amp;gt;
            &amp;lt;phoneNumber&amp;gt;+1 (111) 222-333&amp;lt;/phoneNumber&amp;gt;
            &amp;lt;zipCode&amp;gt;12345&amp;lt;/zipCode&amp;gt;
            &amp;lt;name&amp;gt;Me Formal&amp;lt;/name&amp;gt;
            &amp;lt;contactType&amp;gt;United States&amp;lt;/contactType&amp;gt;
          &amp;lt;/partyContact&amp;gt;
        &amp;lt;/partyContacts&amp;gt;
      &amp;lt;/info&amp;gt;
    &amp;lt;/infoList&amp;gt;
  &amp;lt;/form&amp;gt;
  &amp;lt;Information&amp;gt;
    &amp;lt;Number&amp;gt;11,222,333&amp;lt;/Number&amp;gt;
    &amp;lt;IssueDate&amp;gt;2023-12-12&amp;lt;/IssueDate&amp;gt;
    &amp;lt;ApprovalDate&amp;gt;2017-11-30&amp;lt;/ApprovalDate&amp;gt;
    &amp;lt;ExpirationDate&amp;gt;2035-11-06&amp;lt;/ExpirationDate&amp;gt;
    &amp;lt;SubType&amp;gt;Y&amp;lt;/SubType&amp;gt;
    &amp;lt;Status&amp;gt;SUCCESS&amp;lt;/Status&amp;gt;
  &amp;lt;/Information&amp;gt;
  &amp;lt;index/&amp;gt;
  &amp;lt;additionalInfo&amp;gt;
    &amp;lt;attributes&amp;gt;
      &amp;lt;attribute description="title" name="title" value="Letter"/&amp;gt;
    &amp;lt;/attributes&amp;gt;
    &amp;lt;fileDetails&amp;gt;
      &amp;lt;fileDetail&amp;gt;
        &amp;lt;Toc&amp;gt;application||form&amp;lt;/Toc&amp;gt;
        &amp;lt;title&amp;gt;FABDC REDS&amp;lt;/title&amp;gt;
        &amp;lt;fileName&amp;gt;file.pdf&amp;lt;/fileName&amp;gt;
        &amp;lt;fileType&amp;gt;pdf&amp;lt;/fileType&amp;gt;
        &amp;lt;formType&amp;gt;Long sting of data&amp;lt;/formType&amp;gt;
        &amp;lt;filePath&amp;gt;\\filepath\file.pdf&amp;lt;/filePath&amp;gt;
      &amp;lt;/fileDetail&amp;gt;
      &amp;lt;fileDetail&amp;gt;
        &amp;lt;abcdToc&amp;gt;v1-place||v1-2-file-name&amp;lt;/abcdToc&amp;gt;
        &amp;lt;title&amp;gt;Letter&amp;lt;/title&amp;gt;
        &amp;lt;fileName&amp;gt;letter.pdf&amp;lt;/fileName&amp;gt;
        &amp;lt;fileType&amp;gt;pdf&amp;lt;/fileType&amp;gt;
        &amp;lt;filePath&amp;gt;\\us\letter.pdf&amp;lt;/filePath&amp;gt;
      &amp;lt;/fileDetail&amp;gt;
      &amp;lt;fileDetail&amp;gt;
        &amp;lt;abcdToc&amp;gt;information&amp;lt;/abcdToc&amp;gt;
        &amp;lt;title&amp;gt;11-222-333&amp;lt;/title&amp;gt;
        &amp;lt;fileName&amp;gt;11-222-333.pdf&amp;lt;/fileName&amp;gt;
        &amp;lt;fileType&amp;gt;pdf&amp;lt;/fileType&amp;gt;
        &amp;lt;filePath&amp;gt;\\ab\11-222-333.pdf&amp;lt;/filePath&amp;gt;
      &amp;lt;/fileDetail&amp;gt;
    &amp;lt;/fileDetails&amp;gt;
    &amp;lt;tags/&amp;gt;
  &amp;lt;/additionalInfo&amp;gt;
&amp;lt;/Message&amp;gt;"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the end, I am trying to get the data from the "&amp;lt;fileDetails&amp;gt;" section, specifically the "&amp;lt;title&amp;gt;" for each file. It would have to be multi-value since there may, for a single record, be a single OR multiple Titles.&lt;/P&gt;&lt;P&gt;I've tried a few variations of spath, as well as xmlkv, but as of yet haven't found anything that has given me the results I am expecting.&lt;BR /&gt;For the example above I would expect to have 3 "Titles":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FABDC REDS
Letter
11-222-333&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas how to get this data out?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 14:45:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673791#M230688</guid>
      <dc:creator>tkwaller1</dc:creator>
      <dc:date>2024-01-10T14:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract Title from this XML data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673803#M230690</link>
      <description>&lt;P&gt;With the assumption the field MSG_DATA is properly extracted and a valid XML object then I think this SPL will get you a MV field of "file_title".&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
    | eval
        file_title=coalesce(spath(MSG_DATA, "Message.additionalInfo.fileDetails{}.fileDetail.title"), spath(MSG_DATA, "Message.additionalInfo.fileDetails.fileDetail.title"))&lt;/LI-CODE&gt;&lt;P&gt;Screenshot of it on my local instance:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1704900980599.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28838iCACF9F301E33FB27/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1704900980599.png" alt="dtburrows3_0-1704900980599.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 15:36:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673803#M230690</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-10T15:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract Title from this XML data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673812#M230691</link>
      <description>&lt;P&gt;To extract a single field from the event, I'd use the &lt;FONT face="courier new,courier"&gt;rex&lt;/FONT&gt; command.&amp;nbsp; It will give you a multi-value field with all of the title values.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 "\&amp;lt;title&amp;gt;(?&amp;lt;title&amp;gt;[^\&amp;lt;]+)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 16:09:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673812#M230691</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-01-10T16:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract Title from this XML data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673914#M230711</link>
      <description>&lt;P&gt;Unfortunately, Splunk cannot automatically extract MSG_DATA correctly because the XML document contains double quote. &amp;nbsp;If MSG_DATA is always the last field in the event, you can use&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval MSG_DATA = replace(_raw, ".+,\s*MSG_DATA=\"|\"$", "")
| spath input=MSG_DATA path=Message.additionalInfo.fileDetails.fileDetail.title
| table Message.additionalInfo.fileDetails.fileDetail.title&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your sample data (which includes an invalid fragment that I remove) results in&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Message.additionalInfo.fileDetails.fileDetail.title&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;DIV class=""&gt;FABDC REDS&lt;/DIV&gt;&lt;DIV class=""&gt;Letter&lt;/DIV&gt;&lt;DIV class=""&gt;11-222-333&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Normally, I advise against treating structured data as text. &amp;nbsp;But if you cannot be certain that MSG_DATA is the last field and cannot be certain of the exact terms that follows MSG_DATA, rex as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;suggested would be more stable.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 10:09:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673914#M230711</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-01-11T10:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract Title from this XML data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673945#M230716</link>
      <description>&lt;P&gt;I like this answer, unfortunately I am going to have to update the props for this since as it is not being recognized as a valid xml object and therefore doesn't work. Thanks for the assistance, I greatly appreciate you help!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 14:25:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673945#M230716</guid>
      <dc:creator>tkwaller1</dc:creator>
      <dc:date>2024-01-11T14:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract Title from this XML data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673946#M230717</link>
      <description>&lt;LI-CODE lang="markup"&gt;max_match=0&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Thats what I didn't include, I completely spaced that option. Thanks as always!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 15:04:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-Title-from-this-XML-data/m-p/673946#M230717</guid>
      <dc:creator>tkwaller1</dc:creator>
      <dc:date>2024-01-11T15:04:58Z</dc:date>
    </item>
  </channel>
</rss>

