我试图按日期排序我的xml,但它没有像我这样工作我的xml和xsl r xsl:template match="/" xsl:for-each select="news/item" xsl:sort select="date1" order="descending" / xsl:value-of select="date1"/ /xsl:for-each /xsl:template M
<xsl:template match="/">
<xsl:for-each select="news/item">
<xsl:sort select="date1" order="descending" />
<xsl:value-of select="date1"/>
</xsl:for-each>
</xsl:template>
MYXML
<news>
<item>
<date1>January 1, 2010</date1>
</item>
<item>
<date1>November 29, 2009</date1>
</news>
Its displaying the result but not in sorted way..
xsl-sort不“知道”如何对日期进行排序.尽管您可以使用data-type属性指定数字排序,但它将使用默认值进行文本排序.
有几种方法可以解决这个问题 – add an attribute或更改如何将日期输出到源XML,因此您必须使用数字排序的表示.
