开发者

Date formatting with XSLT / XPath

开发者 https://www.devze.com 2023-04-12 11:58 出处:网络
I have an XML document with the following node: <date>09/01/2012</date> How can i format the date with XSLT to retrieve another representation of the date?

I have an XML document with the following node:

<date>09/01/2012</date>

How can i format the date with XSLT to retrieve another representation of the date?

Here ist the expected resul开发者_C百科t:

<date>2012-01-09</date>

I tried the following rule, but it returns an empty string (i suppose because of the uncommon date input format):

<date><xsl:value-of select="format-date(date, '[Y0001]-[M01]-[D01]')"/></date>


Thanks to Abdullah Battal, i came up with the following solution:

<xsl:value-of select="concat(substring(date, 7, 4), '-', substring(date, 4, 2), '-', substring(date, 1, 2))"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号