我希望訂單列表元素與輸出JSON文件中的輸入XML文件相同。我嘗試使用XSLT,但它不工作標記元素未進入JSON輸出
我輸入XML文件是:
<description>
<p>This medicine is classified as a GLP-1 receptor agonist.</p>
<ol>
<li>Use this medicine once a week</li>
</ol>
</description>
我使用的XSL是:
<xsl:template match="description">
description:
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="p">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="ol">
<ol><xsl:apply-templates/></ol>
</xsl:template>
<xsl:template match="li">
<li><xsl:apply-templates/></li>
</xsl:template>
輸出XML,我得到的是:
description: 'This medicine is classified as a b : "GLP-1 receptor agonist."'
Use this medicine once a week
我期待輸出JSON爲:
description: 'This medicine is classified as a b : "GLP-1 receptor agonist."'
<ol><li>Use this medicine once a week</li></ol>
這是可能的XML到JSON轉換?
請檢查並提供給我正確的XSLT代碼。提前致謝。
您輸入XML和輸出不匹配。文本如何改變? – ScanQR