加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 使用XPath格式化日期

发布时间:2020-12-16 22:42:45 所属栏目:百科 来源:网络整理
导读:我有以下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函数吗?
我有以下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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读