...Technology Simplified

Wednesday, July 11, 2012

How to display current Date and Time in XSLT using C#

No comments :
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:my="put-your-namespace-uri-here"
exclude-result-prefixes="msxsl my">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<msxsl:script language="C#" implements-prefix="my">
public string NowDate(){
return DateTime.Now.ToString("ddMMyyyy");
}
public string NowTime(){
return DateTime.Now.ToString("hhmmss");
}
</msxsl:script>
<xsl:template match="/">
<xsl:value-of select="my:NowDate()" />
<xsl:value-of select="my:NowTime()" />
</xsl:template>
</xsl:stylesheet>

No comments :

Post a Comment