我有以下 XML 并想使用 XSLT 从有效负载中删除 xml 声明。请建议。输入
<?xml version="1.0" encoding="utf-8"?>
<1>
<a>test1</a>
<a>test2</a>
</1>
Run Code Online (Sandbox Code Playgroud)
输出:
<1>
<a>test1</a>
<a>test2</a>
</1>
Run Code Online (Sandbox Code Playgroud)
使用xsl:output标签
<xsl:output method="xml" omit-xml-declaration="yes" />
Run Code Online (Sandbox Code Playgroud)
随着身份变换
<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>