控制 JSON 中 xml 的序列化

问题描述 投票:0回答:1
xslt-2.0 xslt-3.0
1个回答
0
投票

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。

© www.soinside.com 2019 - 2024. All rights reserved.