I want to learn how to search for a word in xml file and delete the entire line using xslt
Example: abc.xml
<server>
<mbean code="org.jboss.varia.property.SystemPropertiesService"
name="abc.props:type=Service,name=abcprop">
<attribute name="Properties">
abc.def.ghi=123
ghi.klm.nop=123
qrst.tuv.wxy=123
zab.cde.fgh=123
ijk.lmn.opq=remove
rst.uvw.xyz=123
abc.tuv.nop=123
ajc.dzf.goi=123
</attribute>
</mbean>
</server>
From the above example I want to search for a word "remove" and delete the complete line: ijk.lmn.opq=remove
Expected output is:
<server>
<mbean code="org.jboss.varia.property.SystemPropertiesService"
name="abc.props:type=Service,name=abcprop">
<attribute name="Properties">
abc.def.ghi=123
ghi.klm.nop=123
qrst.tuv.wxy=123
zab.cde.fgh=123
rst.uvw.xyz=123
abc.tuv.nop=123
ajc.dzf.goi=123
</attribute>
</mbean>
</server>
Update:
I tried the following code
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[(@* != 'DELETE')]"/>
</xsl:stylesheet>
Some how its not working, its deleting every thing in an xml file and showing an empty file.