我有以下XML并且需要对其进行转换。
XML:<Assessment>
<Section ID="Listening">24</Section>
<Section ID="Writing">10</Section>
<Section ID="Reading">30</Section>
<Section ID="ABC">22</Section>
</Assessment>
输出:
Listening-24
Writing-10
Reading-30
ABC-22
我尝试了以下代码,但我无法在输出中获得评分。 如何在评估中获得价值?
XSL:
enter code here
<xsl:for-each select="Assessment/Section">
<xsl:value-of select="@ID"></xsl:value-of>
<xsl:value-of select="$delimiter"></xsl:value-of>
<xsl:value-of select="Section"></xsl:value-of>
<xsl:value-of select="$linefeed"></xsl:value-of>
</xsl:for-each>
请提供帮助以修复此代码。
答案 0 :(得分:0)
尝试:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/Assessment">
<xsl:for-each select="Section">
<xsl:value-of select="@ID"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>