我有以下 XML 并希望使用 XSLT 从有效负载中删除 xml 声明。请建议。 输入
<?xml version="1.0" encoding="utf-8"?>
<1>
<a>test1</a>
<a>test2</a>
</1>
输出:
<1>
<a>test1</a>
<a>test2</a>
</1>
最佳答案
使用 xsl:output
标签
<xsl:output method="xml" omit-xml-declaration="yes" />
身份转换
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
关于xslt - 使用 xslt 删除 XML 声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37998443/