shiva tatikonda
shiva tatikonda

Reputation: 101

How to remove character from string using xslt?

<Scheduled>
 <xsl:value-of select="//RequestParameters/Identifier/DepartureDate">
 </xsl:value-of>
 </Scheduled> 

In this xslt code iam getting a last character as 'z' in "//RequestParameters/Identifier/DepartureDate" i want to remove z and please help on this.

Upvotes: 1

Views: 6732

Answers (2)

Maestro13
Maestro13

Reputation: 3696

In general, you may want to convert an element value in ISO 8601 date format to another format by adding a javascript function to your xslt, and call that function in your Xpath expression. For instance, when you have added a (javascript) function convertToDate that extracts the date part of the input value in the format yyyymmdd, the Xpath expression

convertToDate (//RequestParameters/Identifier/DepartureDate)

will result in a value

20111016

assuming there is only one DepartureDate element in the input, having value

2011-10-16T09:40:00.000Z

Upvotes: 0

snak
snak

Reputation: 6703

If the value of //RequestParameters/Identifier/DepartureDate contains 'z' only at the end, you can use substring-before function.

<xsl:value-of select="substring-before(//RequestParameters/Identifier/DepartureDate, 'z')">

edit:

If you want to get the first 10 characters of the value, you can use substring function.

<xsl:value-of select="substring(//RequestParameters/Identifier/DepartureDate, 1, 10)">

Upvotes: 3

Related Questions