JSON 输出可以序列化节点所以
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all">
<xsl:output method="json" indent="yes"/>
<xsl:template match="/">
<xsl:sequence select="map { 'xmlData' : . }"/>
</xsl:template>
</xsl:stylesheet>
给出例如(撒克逊 HE 12.3)
{ "xmlData":"<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\">\n<\/Workbook>" }
所以基本上我不确定为什么你尝试在自己的代码中序列化 XML。