Rose
Rose

Reputation: 1498

How to remove substring from XML using XSLT

I am a newbie with XSLT. I have an XML file which has many values for a tag

<submitTime>2016-06-09T18:27:56+0000</submitTime>
<submitTime>2016-06-09T18:13:10+0000</submitTime>
.......

I want to convert this submitTime date format into this format(YYYY-MM-DD):

<submitTime>2016-06-09</submitTime>

How can I remove the time from date format? Any help would be appreciated!

Upvotes: 1

Views: 1167

Answers (1)

Daniel Haley
Daniel Haley

Reputation: 52858

Since the submitTime value is so consistent, you can simply use substring-before()...

<xsl:value-of select="substring-before(.,'T')"/>

Note: The above xsl:value-of assumes the context is submitTime.

Upvotes: 3

Related Questions