<?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: Search, XPATH and XPATH namespaces in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Search-XPATH-and-XPATH-namespaces/m-p/648868#M110283</link>
    <description>&lt;P&gt;You can't match any events this way since you're trying to find "xpath" as a literal term included in your event.&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jul 2023 08:08:00 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2023-07-01T08:08:00Z</dc:date>
    <item>
      <title>Search, XPATH and XPATH namespaces</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-XPATH-and-XPATH-namespaces/m-p/642300#M109466</link>
      <description>&lt;P&gt;I have an index populated with data from a Log4Net trace log.&amp;nbsp; Each Splunk event in the index is a block of XML with an XML namespace:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"&amp;gt;
	&amp;lt;System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"&amp;gt;
		&amp;lt;EventID&amp;gt;0&amp;lt;/EventID&amp;gt;
		&amp;lt;Type&amp;gt;3&amp;lt;/Type&amp;gt;
		&amp;lt;SubType Name="Information"&amp;gt;0&amp;lt;/SubType&amp;gt;
		&amp;lt;Level&amp;gt;8&amp;lt;/Level&amp;gt;
		&amp;lt;TimeCreated SystemTime="04/22/2023 12:30:45.0456293Z"/&amp;gt;
		&amp;lt;Source Name="Bar"/&amp;gt;
		&amp;lt;Correlation ActivityID="{459d276d-8255-47be-be1d-9acd903fd3f0}"/&amp;gt;
		&amp;lt;Execution ProcessName="NA" ProcessID="1124" ThreadID="9"/&amp;gt;
		&amp;lt;Channel/&amp;gt;
		&amp;lt;Computer&amp;gt;NA&amp;lt;/Computer&amp;gt;
	&amp;lt;/System&amp;gt;
	&amp;lt;ApplicationData&amp;gt;
		&amp;lt;TraceData&amp;gt;
			&amp;lt;DataItem&amp;gt;
				&amp;lt;TraceRecord Severity="Information"&amp;gt;
					&amp;lt;TraceIdentifier/&amp;gt;
					&amp;lt;Description&amp;gt;&amp;lt;![CDATA[Start Operation: foo]]&amp;gt;&amp;lt;/Description&amp;gt;
					&amp;lt;Activity&amp;gt;&amp;lt;![CDATA[Start Operation: foo]]&amp;gt;&amp;lt;/Activity&amp;gt;
					&amp;lt;Duration&amp;gt;0&amp;lt;/Duration&amp;gt;
				&amp;lt;/TraceRecord&amp;gt;
			&amp;lt;/DataItem&amp;gt;
		&amp;lt;/TraceData&amp;gt;
	&amp;lt;/ApplicationData&amp;gt;
&amp;lt;/E2ETraceEvent&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;I am trying to search these events, and I want the contents of the "Description" XML element.&amp;nbsp; Does Splunk's implementation of XPATH support namespaces?&amp;nbsp; &amp;nbsp;This search is returning no records:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="lmstracelogs" xpath "//E2ETraceEvent/ApplicationData/TraceData/DataItem/TraceRecord/Description"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Almost every example I've found for working with XML suggests regular expressions, which seems inelegant.&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 13:35:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-XPATH-and-XPATH-namespaces/m-p/642300#M109466</guid>
      <dc:creator>DWRoelands</dc:creator>
      <dc:date>2023-05-04T13:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Search, XPATH and XPATH namespaces</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-XPATH-and-XPATH-namespaces/m-p/648857#M110280</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/256451"&gt;@DWRoelands&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;This may not be the most elegant, but to avoid regex you can use:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| xpath outfield=description "/*[name()='E2ETraceEvent' and  namespace-uri()='http://schemas.microsoft.com/2004/06/E2ETraceEvent' ]/*[name()='ApplicationData']/*[name()='TraceData']/*[name()='DataItem']/*[name()='TraceRecord']/*[name()='Description']"&lt;/LI-CODE&gt;&lt;P&gt;That creates a description field with the correct text:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="danspav_1-1688190757690.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/26101iB4DD03AF0A05C3C7/image-size/large?v=v2&amp;amp;px=999" role="button" title="danspav_1-1688190757690.png" alt="danspav_1-1688190757690.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It does obey the namespace, but it's not the easiest to read.&lt;BR /&gt;&lt;BR /&gt;Falling back to regex, if you run a sedcmd you can strip the namespaces and use your original xpath:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex mode=sed "s/xmlns=\"[^\"]+\"//g"
| xpath outfield=description "//E2ETraceEvent/ApplicationData/TraceData/DataItem/TraceRecord/Description"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2023 06:02:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-XPATH-and-XPATH-namespaces/m-p/648857#M110280</guid>
      <dc:creator>danspav</dc:creator>
      <dc:date>2023-07-01T06:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Search, XPATH and XPATH namespaces</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-XPATH-and-XPATH-namespaces/m-p/648858#M110281</link>
      <description>&lt;P&gt;Alternatively, just run:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path="E2ETraceEvent.ApplicationData.TraceData.DataItem.TraceRecord.Description" output=description&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 01 Jul 2023 06:06:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-XPATH-and-XPATH-namespaces/m-p/648858#M110281</guid>
      <dc:creator>danspav</dc:creator>
      <dc:date>2023-07-01T06:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Search, XPATH and XPATH namespaces</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-XPATH-and-XPATH-namespaces/m-p/648868#M110283</link>
      <description>&lt;P&gt;You can't match any events this way since you're trying to find "xpath" as a literal term included in your event.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2023 08:08:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-XPATH-and-XPATH-namespaces/m-p/648868#M110283</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-07-01T08:08:00Z</dc:date>
    </item>
  </channel>
</rss>

