I have the following xpath expressions...
//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)
I need to format and concat these values into something like this
2011-08-25T17:35:00
Is this possible to do using xpath functions? An example would be appreciated.
The date format in the input data is dd/mm/yyyy.
As by @Michael Key suggestion (+1), three substring()
and one concat()
is all what you need. Check at this XSLT example using the XPath you are searching for (use of variables to make expression readable):
<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>
It would help to know whether your 01/01/2011 is d/m/y or m/d/y. Either way, it's just a question of calling substring() three times to extract the parts of the data, and then concat() to build up the result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With