canyou solve this prob, i wt to remove specific type element
Posted: Fri Jan 18, 2008 12:27 pm
Hi all
Any body is there who can help me….
I have xml file…..
<Project>
<Body>
<TXT><TXT>
<TXT>Hello TXT <TXT>
<Model><Model>
<Model>hello model<Model>
<Body>
</Project>
In this xml file two TXT element one is empty & other has value
I want to remove the empty elpement…
want the output like this
<Project>
<Body>
(don’t want TXT element)
<TXT>Hello TXT <TXT>
<Model><Model>
<Model>hello model<Model>
<Body>
</Project>
I wrote one xslt file
Like this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:if test=". != '' ">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
By this xslt , I got the output like this
<Project>
<Body>
<TXT>Hello TXT <TXT>
<Model>hello model<Model>
<Body>
</Project>
This xslt file remove both empty element “<TXT>â€,â€<Model>â€
But I want to remove only one <TXT>
Help me….please
Any body is there who can help me….
I have xml file…..
<Project>
<Body>
<TXT><TXT>
<TXT>Hello TXT <TXT>
<Model><Model>
<Model>hello model<Model>
<Body>
</Project>
In this xml file two TXT element one is empty & other has value
I want to remove the empty elpement…
want the output like this
<Project>
<Body>
(don’t want TXT element)
<TXT>Hello TXT <TXT>
<Model><Model>
<Model>hello model<Model>
<Body>
</Project>
I wrote one xslt file
Like this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:if test=". != '' ">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
By this xslt , I got the output like this
<Project>
<Body>
<TXT>Hello TXT <TXT>
<Model>hello model<Model>
<Body>
</Project>
This xslt file remove both empty element “<TXT>â€,â€<Model>â€
But I want to remove only one <TXT>
Help me….please