How to extract this date format in xslt [duplicate]
I have an xml structure:
<Date>Mon, 11 Aug 2009 13:15:10 GMT</Date>
i want to extract only 13:15 or '13' and '15'. What is the best way to do that using xslt
This is a simple modification from my answer in your previous question so all the same there mentioned restrictions apply here also.
<xsl:variable name="time" select="substring(Date, string-length(substring-before(Date, ':') - 1, 5)"/>
If you can use XPath 2.0, you could use tokenize():
XML
<?xml version="1.0" encoding="UTF-8"?>
<Date>Mon, 11 Aug 2009 13:15:10 GMT</Date>
XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/Date">
<xsl:value-of select="tokenize(tokenize(.,' ')[5],':')[position() < 3]"/>
</xsl:template>
</xsl:stylesheet>
OUTPUT
13 15
精彩评论