Xml 使用XPath格式化日期

Xml 使用XPath格式化日期,xml,soap,xpath,soapui,Xml,Soap,Xpath,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) 我需要将这些值格式化并压缩成这样 2011-08-25T17:35:00 使用xpath函数可以做到这一点吗?请举个例子 输入数据中的日期格式为dd/mm/yyyy。查看XPath 1.0函数:con

我有以下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。

查看XPath 1.0函数:
concat
子字符串
前子字符串
后子字符串
,这将有助于了解您的2011年1月1日是d/m/y还是m/d/y。无论哪种方式,都只需要调用substring()三次来提取部分数据,然后调用concat()来构建结果。

正如@Michael Key suggestion(+1)所述,三个
substring()
和一个
concat()
就是您所需要的。使用正在搜索的XPath检查此XSLT示例(使用变量使表达式可读):



您使用的XPath版本是什么?不确定,它包含在SoapUI 4.0中。您好,请详细说明如何在SoapUI中实现它,以及在何处实现它?
<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>