I have the following XML file
<?xml version="1.0" encoding="utf-8"?>
<article>
<Details>
<date>Posted: 08/22/2011 </date>
<title>Hi this is Jake. I am Smart</title>
<text></text>
</Details>
</article>
I have the following XLST to remove the Details and /Details tag
<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="Details"><xsl:apply-templates/></xsl:template>
Output expected
<?xml version="1.0" encoding="utf-8"?>
<article>
<date>Posted: 08/22/2011 </date>
<title>Hi this is Jake. I am Smart</title>
<text></text>
</article>
I tried this. But it is not removing the "Details" and "/Details" tag.
This
<xsl:template match="Details"><xsl:apply-templates/></xsl:template>
will remove <Details>
itself, but it will also process its contents. Use
<xsl:template match="Details" />
to remove it entirely (tag and contents).
(If <Details>
still appears in your output, then your question is not complete.)
精彩评论