使用 XPath 设置日期格式

Rem*_*tec 4 xml xpath soap soapui

我有以下 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)
Run Code Online (Sandbox Code Playgroud)

我需要将这些值格式化并连接成这样的内容

2011-08-25T17:35:00
Run Code Online (Sandbox Code Playgroud)

使用 xpath 函数可以做到这一点吗?举个例子将不胜感激。

输入数据中的日期格式为 dd/mm/yyyy。

Emi*_*ggi 5

正如@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),'-',
        substring($sD,1,2),'T',
        $sT,':00')"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)