<?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 regex to get xml (Element Name + Value) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/regex-to-get-xml-Element-Name-Value/m-p/20947#M3356</link>
    <description>&lt;P&gt;I have a  xml-field with two different Elements :&lt;BR /&gt;
    &lt;SUBELEMENT&gt;&lt;BR /&gt;
    &lt;ELEMENT1&gt;&lt;BR /&gt;
    ...&lt;BR /&gt;
    &lt;/ELEMENT1&gt;&lt;BR /&gt;
    &lt;ELEMENT2&gt;&lt;BR /&gt;
    ...&lt;BR /&gt;
    &lt;/ELEMENT2&gt;&lt;BR /&gt;
    &lt;/SUBELEMENT&gt;&lt;/P&gt;

&lt;P&gt;I wanted to extract the 2 Elements, but also knowing after extract, where the info is coming form.&lt;/P&gt;

&lt;P&gt;If I make something like that :&lt;BR /&gt;
&amp;lt;(Element1|Element2)\b[^&amp;gt;]&lt;EM&gt;&amp;gt;(?P&lt;ELEMENT&gt;.&lt;/ELEMENT&gt;&lt;/EM&gt;)&amp;lt;/(Element1|Element2)&lt;/P&gt;

&lt;P&gt;Then I have the multivalued element "element", but I don't know it the data in it, is form Element1 or 2&lt;/P&gt;

&lt;P&gt;Is it possible to have regex extracting the whole element with tag ? like &lt;BR /&gt;
element=    &lt;ELEMENT1&gt;...&lt;/ELEMENT1&gt;&lt;BR /&gt;
            &lt;ELEMENT2&gt;...&lt;/ELEMENT2&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 01 May 2013 11:15:41 GMT</pubDate>
    <dc:creator>sbsbb</dc:creator>
    <dc:date>2013-05-01T11:15:41Z</dc:date>
    <item>
      <title>regex to get xml (Element Name + Value)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-to-get-xml-Element-Name-Value/m-p/20947#M3356</link>
      <description>&lt;P&gt;I have a  xml-field with two different Elements :&lt;BR /&gt;
    &lt;SUBELEMENT&gt;&lt;BR /&gt;
    &lt;ELEMENT1&gt;&lt;BR /&gt;
    ...&lt;BR /&gt;
    &lt;/ELEMENT1&gt;&lt;BR /&gt;
    &lt;ELEMENT2&gt;&lt;BR /&gt;
    ...&lt;BR /&gt;
    &lt;/ELEMENT2&gt;&lt;BR /&gt;
    &lt;/SUBELEMENT&gt;&lt;/P&gt;

&lt;P&gt;I wanted to extract the 2 Elements, but also knowing after extract, where the info is coming form.&lt;/P&gt;

&lt;P&gt;If I make something like that :&lt;BR /&gt;
&amp;lt;(Element1|Element2)\b[^&amp;gt;]&lt;EM&gt;&amp;gt;(?P&lt;ELEMENT&gt;.&lt;/ELEMENT&gt;&lt;/EM&gt;)&amp;lt;/(Element1|Element2)&lt;/P&gt;

&lt;P&gt;Then I have the multivalued element "element", but I don't know it the data in it, is form Element1 or 2&lt;/P&gt;

&lt;P&gt;Is it possible to have regex extracting the whole element with tag ? like &lt;BR /&gt;
element=    &lt;ELEMENT1&gt;...&lt;/ELEMENT1&gt;&lt;BR /&gt;
            &lt;ELEMENT2&gt;...&lt;/ELEMENT2&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2013 11:15:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-to-get-xml-Element-Name-Value/m-p/20947#M3356</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-05-01T11:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: regex to get xml (Element Name + Value)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-to-get-xml-Element-Name-Value/m-p/20948#M3357</link>
      <description>&lt;P&gt;If you want to include the tags in your field value you just need to move them into the parentheses and make sure the closing tags don't get greedily overlooked:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?P&amp;lt;element&amp;gt;&amp;lt;element[12]\b[^&amp;gt;]*&amp;gt;.*?&amp;lt;/element[12]&amp;gt;)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2013 13:23:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-to-get-xml-Element-Name-Value/m-p/20948#M3357</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-05-01T13:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: regex to get xml (Element Name + Value)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/regex-to-get-xml-Element-Name-Value/m-p/20949#M3358</link>
      <description>&lt;P&gt;It works, many thanks !&lt;/P&gt;

&lt;P&gt;Because the element Name is complete different, I've adapted your answer to &lt;/P&gt;

&lt;P&gt;(?P&lt;TARGET&gt;&amp;lt;(element1|element2)\b[^&amp;gt;]&lt;EM&gt;&amp;gt;.&lt;/EM&gt;?&amp;lt;/(element1|element2)&amp;gt;)&lt;/TARGET&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2013 07:57:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/regex-to-get-xml-Element-Name-Value/m-p/20949#M3358</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-05-02T07:57:47Z</dc:date>
    </item>
  </channel>
</rss>

