Can anyone please guilde me with this. I am trying to locate a particular tag, based on it child's contents and remove the parent tag and contents and add a new contents, but cant find an answer. Here is my xml:<?xml version=1.0 encoding=ISO-8859-1?><!DOCTYPE appPUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//ENhttp://java.sun.com/dtd/web-app_2_3.dtd><app><displayname>Admin</displayname><filter> <filtername>accesslog</filtername> <filterclass>com.filter.accesslog</filterclass></filter><filter>  <filtername>ServerHealthCheckFilter</filtername>  <filterclass>com.filter.ServerHealthCheckFilter</filterclass></filter></app>What I want to do is to search <filtername>accesslog</filtername> exists in a <filter> block, if it does i want to delete the whole <filter> block which the <filtername>accesslog</filtername> in its parent and add a new content. So the result would be:  <displayname>Admin</displayname><filter> <filtername>accesslog</filtername> <filterclass>com.logclient.filter.accesslog</filterclass> <initparam>   <param-name>logClientName</param-name>   <param-value>com.logging.AccessLogImpl</param-value>  </initparam></filter><filter>  <filtername>ServerHealthCheckFilter</filtername>  <filterclass>com.filter.ServerHealthCheckFilter</filterclass></filter>I'm just trying my first xsl to delete content first. Here it is: modifyxml.xsl<xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform><xsl:output  method = xml   version = 1.0   encoding = ISO-8859-1  omit-xml-declaration = yes  doctype-public = -//Sun Microsystems, Inc.//DTD Web Application 2.3//ENhttp://java.sun.com/dtd/web-app_2_3.dtd  indent = yes/><xsl:output omit-xml-declaration=yes/><xsl:template match=node()|@*><xsl:copy>  <xsl:apply-templates select=node()|@*/></xsl:copy></xsl:template><xsl:template match=filter[filter-name = 'accesslog']/></xsl:stylesheet>I get errors. modifyxml.xsl:8: parser error : error parsing attribute namehttp://java.sun.com/dtd/web-app_2_3.dtd^modifyxml.xsl:8: parser error : attributes construct errorhttp://java.sun.com/dtd/web-app_2_3.dtd^modifyxml.xsl:8: parser error : Couldn't find end of Start Tag output line 2http://java.sun.com/dtd/web-app_2_3.dtd^
Remove tag and contents based on child tag and add a new content - Shellscript xml
shell script;xml
You should not try to parse XML with a shell script. Look for a purpose built tool like xsltproc.