Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2013, 02:56 PM
Registered User
 
Join Date: Sep 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cognito Send a message via Yahoo to cognito
Default Convert XML String to Datetime/Timestamp

Hi. I have a project where I pull data from an xml file using xslt. I was successful in doing so, however, one of the xml field is a date in this format.
2013-09-17 11:48:26
the xml file looks like this:
<Fields>
<Field Name="datePurchased" Value ="2013-09-17 11:48:26"/>
<Field Name="customerName" Value = "James" />
<Field Name="customerItem" Value = "Bottled water" />
</Fields>

I want the output to be this

<![CDATA[2013/09/17 11:48:26.0 EDT]]

By the way: I am super new to xslt.
 
Old September 26th, 2013, 05:27 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

The following does what you ask - whether that is what you actually wanted or not is another matter.

Code:
<xsl:value-of select="concat(translate(/Fields/Field[@Name='datePurchased']/@Value, '-', '/'),'.0 EDT')"/>
Basically it just treats the attribute as a string (which it is).
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert String to DateTime SimoNWellborne C# 3 October 11th, 2014 02:24 AM
convert string to datetime in VB.net lisabb ASP.NET 2.0 Basics 3 June 19th, 2007 06:52 AM
How to convert a string in DateTime elena SQL Language 6 March 29th, 2006 06:59 PM
Convert string to datetime nkovacevic General .NET 4 April 5th, 2005 11:57 AM
How to convert a string in DateTime elena ADO.NET 3 July 24th, 2003 04:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.