> I'm reading data from an XML file using the XmlDocument class. Some
> elements are of type xs:dateTime. Is there a way to convert a xs:dateTime
> value to a standard DateTime object?
Look at XmlConvert which has a ToString(DateTime) method to convert a
.NET DateTime to a string complying with xs:dateTime and a method
ToDateTime(string) to convert a xs:dateTime string into a .NET DateTime
object:
using System;
using System.Xml;
public class Test20031028 {
public static void Main (string[] args) {
DateTime now = DateTime.Now;
System.Console.WriteLine("now: " + now);
string schemaDateTime = XmlConvert.ToString(now);
System.Console.WriteLine("XmlConvert.ToString(now): " +
schemaDateTime);
DateTime dt = XmlConvert.ToDateTime(schemaDateTime);
System.Console.WriteLine(dt);
}
}

Signature
Martin Honnen
http://JavaScript.FAQTs.com/
Jens Weiermann - 28 Oct 2003 16:25 GMT
Hi Martin,
> Look at XmlConvert which has a ToString(DateTime) method to convert a
> .NET DateTime to a string complying with xs:dateTime and a method
> ToDateTime(string) to convert a xs:dateTime string into a .NET DateTime
> object: [Snip]
thanks, that did it! Now, is there something similar for the xs:duration
data type? I already found the TimeSpan thingie, but that doesn't seem to
cover xs:duration...
Thanks again!
Jens
Martin Honnen - 29 Oct 2003 15:18 GMT
> thanks, that did it! Now, is there something similar for the xs:duration
> data type? I already found the TimeSpan thingie, but that doesn't seem to
> cover xs:duration...
XmlConvert also has methods ToString(TimeSpan) and ToTimeSpan(string)
thus I think TimeSpan covers xs:duration.

Signature
Martin Honnen
http://JavaScript.FAQTs.com/