<?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: REX SED Help, need to replace namespaces from xml field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172759#M49541</link>
    <description>&lt;P&gt;Sure, simply remove the "h:" from the capture group as such:&lt;BR /&gt;
"s/(&amp;lt;)h:(\S+)\s+(xmlns:\S+)(&amp;gt;)/\1\2\4/g"&lt;/P&gt;</description>
    <pubDate>Mon, 23 Dec 2013 18:43:38 GMT</pubDate>
    <dc:creator>emechler_splunk</dc:creator>
    <dc:date>2013-12-23T18:43:38Z</dc:date>
    <item>
      <title>REX SED Help, need to replace namespaces from xml field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172754#M49536</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a xml field which holds values like below. It contains namespaces for each element which I want to remove:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...message="&amp;lt;h:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&amp;gt;
&amp;lt;h:Header&amp;gt;
&amp;lt;h:creationTimestamp&amp;gt;2013-12-09T16:58:57.2450018+05:30&amp;lt;/h:creationTimestamp&amp;gt;
&amp;lt;h:applicationId&amp;gt;XYZ&amp;lt;/h:applicationId&amp;gt;
&amp;lt;h:hostName&amp;gt;Myhost&amp;lt;/h:hostName&amp;gt;
&amp;lt;/h:Header&amp;gt;
&amp;lt;/h:Envelope&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Obviously there could be more/different namespace values ("h:" prefix) in the the logs, so can't hardcode the value to replace it. I believe REX SED would be the appropriate method for my requirement.&lt;/P&gt;

&lt;P&gt;I am very new to Regex so not able to start with REX SED command. Could anyone provide me some direction/example how to go about it?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2013 18:30:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172754#M49536</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-09T18:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: REX SED Help, need to replace namespaces from xml field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172755#M49537</link>
      <description>&lt;P&gt;If you wanted to do this at index-time (i.e. remove the content from the event before it's indexed into Splunk), then you could use SEDCMD to remove the content via props.conf:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[XML_sourcetype]&lt;BR /&gt;
...&lt;BR /&gt;
SEDCMD-null = s/(&amp;lt;h:\S+)\s+(xmlns:\S+)(&amp;gt;)/\\1\3/g&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If you're doing this inline, then the same regex should work with the rex command:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | rex field=_raw mode=sed "s/(&amp;lt;h:\S+)\s+(xmlns:\S+)(&amp;gt;)/\1\3/g"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2013 19:55:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172755#M49537</guid>
      <dc:creator>emechler_splunk</dc:creator>
      <dc:date>2013-12-09T19:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: REX SED Help, need to replace namespaces from xml field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172756#M49538</link>
      <description>&lt;P&gt;I would like to do this during search time. Unfortunately the above rex command doesn't work for me (event with test data I provided).&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2013 20:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172756#M49538</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-09T20:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: REX SED Help, need to replace namespaces from xml field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172757#M49539</link>
      <description>&lt;P&gt;Sorry, looked like there was an extra backslash in the regex.  Try the updated version above.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2013 21:39:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172757#M49539</guid>
      <dc:creator>emechler_splunk</dc:creator>
      <dc:date>2013-12-09T21:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: REX SED Help, need to replace namespaces from xml field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172758#M49540</link>
      <description>&lt;P&gt;It worked fine and removing all occurrance of xmlns where "&amp;lt;h:" is present. Is is possible to remove the "h:" also so that I will be left with just "&lt;ENVELOP&gt;" instead of "&lt;ENVELOPE S="http://schemas.xmlsoap.org/soap/envelope/"&gt;"&lt;/ENVELOPE&gt;&lt;/ENVELOP&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2013 19:19:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172758#M49540</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-20T19:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: REX SED Help, need to replace namespaces from xml field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172759#M49541</link>
      <description>&lt;P&gt;Sure, simply remove the "h:" from the capture group as such:&lt;BR /&gt;
"s/(&amp;lt;)h:(\S+)\s+(xmlns:\S+)(&amp;gt;)/\1\2\4/g"&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2013 18:43:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172759#M49541</guid>
      <dc:creator>emechler_splunk</dc:creator>
      <dc:date>2013-12-23T18:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: REX SED Help, need to replace namespaces from xml field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172760#M49542</link>
      <description>&lt;P&gt;Another way you could do this at search time is to simply eval the XML portion with a regex replace&lt;/P&gt;

&lt;P&gt;|rex field=_raw "(?i)request=(?.+)$"&lt;/P&gt;

&lt;P&gt;|eval requestXML=replace(XML,"\w+:","")&lt;/P&gt;

&lt;P&gt;|xmlkv requestXML&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 00:32:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-SED-Help-need-to-replace-namespaces-from-xml-field/m-p/172760#M49542</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2016-10-05T00:32:33Z</dc:date>
    </item>
  </channel>
</rss>

