title: Delete nodes in xml if they contain certain text using sed
body: <p>I have an xml that looks like following.</p>
  
  <pre><code>&lt;rootNode&gt;  
     &lt;appender name="SERVER_FILE" class="org.apache.log4j.RollingFileAppender"&gt;
        &lt;param name="File" value="C:/COM_FIND.log"/&gt;
        &lt;param name="Threshold" value="INFO"/&gt;
        &lt;param name="Append" value="true"/&gt;
        &lt;param name="MaxFileSize" value="5000KB"/&gt;
        &lt;param name="MaxBackupIndex" value="5"/&gt;
        &lt;layout class="org.apache.log4j.PatternLayout"&gt;
           &lt;param name="ConversionPattern" value="%d %-5p [%c] %m%n"/&gt;
        &lt;/layout&gt;
     &lt;/appender&gt;   
     &lt;appender name="CAT_FILE" class="org.apache.log4j.RollingFileAppender"&gt;
        &lt;param name="File" value="C:/COM_Now.log"/&gt;
        &lt;param name="Threshold" value="INFO"/&gt;
        &lt;param name="Append" value="true"/&gt;
        &lt;param name="MaxFileSize" value="5000KB"/&gt;
        &lt;param name="MaxBackupIndex" value="2"/&gt;
        &lt;layout class="org.apache.log4j.PatternLayout"&gt;
           &lt;param name="ConversionPattern" value="%d %-5p [%c] %m%n"/&gt;
        &lt;/layout&gt;
     &lt;/appender&gt; 
      &lt;appender name="SERVER_FILE" class="org.apache.log4j.RollingFileAppender"&gt;
           &lt;param name="File" value="C:/COM_A.log"/&gt;
           &lt;param name="Threshold" value="INFO"/&gt;
           &lt;param name="Append" value="true"/&gt;
           &lt;param name="MaxFileSize" value="5000KB"/&gt;
           &lt;param name="MaxBackupIndex" value="5"/&gt;
           &lt;layout class="org.apache.log4j.PatternLayout"&gt;
              &lt;param name="ConversionPattern" value="%d %-5p [%c] %m%n"/&gt;
           &lt;/layout&gt;
     &lt;/appender&gt;   
      &lt;appender name="SERVER_FILE" class="org.apache.log4j.RollingFileAppender"&gt;
           &lt;param name="File" value="C:/COM_Find.log"/&gt;
           &lt;param name="Threshold" value="INFO"/&gt;
           &lt;param name="Append" value="true"/&gt;
           &lt;param name="MaxFileSize" value="5000KB"/&gt;
           &lt;param name="MaxBackupIndex" value="5"/&gt;
           &lt;layout class="org.apache.log4j.PatternLayout"&gt;
              &lt;param name="ConversionPattern" value="%d %-5p [%c] %m%n"/&gt;
           &lt;/layout&gt;
     &lt;/appender&gt;   
     &lt;logger name="com.mycompany"&gt;
        &lt;level value="INFO"/&gt;
        &lt;appender-ref ref="SERVER_FILE"/&gt;
      &lt;/logger&gt;
  &lt;/rootNode&gt;
  </code></pre>
  
  <p>Yes.Its an excerpt from the log4j xml. What i basically want to do is remove all the appender tags/elements (from )that contain the word 'COM_Find.log' using the sed command.
  What i have so far is this :-</p>
  
  <pre><code>sed -e '/&lt;appender/,/&lt;\/appender&gt;/{H;$!d;}' -e 'x;/COM_Find.log/d' file.xml
  </code></pre>
  
  <p>Which does a greedy search from the first appender to the last and deletes everything in between. I just want only those specific appender tags/elements(from ) to be removed. </p>
  
  <p>The output should be:-</p>
  
  <pre><code>&lt;rootNode&gt;  
     &lt;appender name="CAT_FILE" class="org.apache.log4j.RollingFileAppender"&gt;
        &lt;param name="File" value="C:/COM_Now.log"/&gt;
        &lt;param name="Threshold" value="INFO"/&gt;
        &lt;param name="Append" value="true"/&gt;
        &lt;param name="MaxFileSize" value="5000KB"/&gt;
        &lt;param name="MaxBackupIndex" value="2"/&gt;
        &lt;layout class="org.apache.log4j.PatternLayout"&gt;
           &lt;param name="ConversionPattern" value="%d %-5p [%c] %m%n"/&gt;
        &lt;/layout&gt;
     &lt;/appender&gt; 
      &lt;appender name="SERVER_FILE" class="org.apache.log4j.RollingFileAppender"&gt;
           &lt;param name="File" value="C:/COM_A.log"/&gt;
           &lt;param name="Threshold" value="INFO"/&gt;
           &lt;param name="Append" value="true"/&gt;
           &lt;param name="MaxFileSize" value="5000KB"/&gt;
           &lt;param name="MaxBackupIndex" value="5"/&gt;
           &lt;layout class="org.apache.log4j.PatternLayout"&gt;
              &lt;param name="ConversionPattern" value="%d %-5p [%c] %m%n"/&gt;
           &lt;/layout&gt;
     &lt;/appender&gt;   
     &lt;logger name="com.mycompany"&gt;
        &lt;level value="INFO"/&gt;
        &lt;appender-ref ref="SERVER_FILE"/&gt;
      &lt;/logger&gt;
  &lt;/rootNode&gt;
  </code></pre>
  
  <p>Can someone help me?</p>