我有以下xpath表达式…
//ns:response[1]/ns:return[1]/legs[1]/startDate[1] (Value 01/01/2011) //ns:response[1]/ns:return[1]/legs[1]/startTime[1] (Value 12:13)
我需要格式化并将这些值连接成这样的东西
2011-08-25T17:35:00
这可以使用xpath函数吗?一个例子将不胜感激.
输入数据中的日期格式为dd / mm / yyyy.
解决方法
正如@Michael Key建议(1)所示,三个substring()和一个concat()就是你所需要的.使用您要搜索的XPath检查此XSLT示例(使用变量使表达式可读):
<xsl:template match="/"> <xsl:variable name="sD" select="'01/01/2011'"/> <xsl:variable name="sT" select="'12:13'"/> <xsl:value-of select="concat( substring($sD,7),'-',substring($sD,4,2),1,'T',$sT,':00')"/> </xsl:template>