Groups | Blog | Home
all groups > dotnet xml > november 2005 >

dotnet xml : How to handle empty datetime if read by ReadXML


GossTremontTech
11/30/2005 7:52:15 AM
Hi,

We have a webservice that generates an xml string that has a empty/null
datetime field (<OurDate></Ourdate>). When we use ReadXML read in the
serialized string we get the error:

"string not recognized as a valid datetime"

Our code looks like this:

Dim sReader As New StringReader("data.xml")
myDataset.ReadXml(sReader)

Is there a strategy to handle blank dates you can suggest.

Thanks,

J Goss



Zafar Abbas
11/30/2005 11:24:19 AM
null values are not valid instances of the dateTime datatype. You have to
either put xsi:nil="true" on the XML or change the type to string.

"GossTremontTech" <GossTremontTech@discussions.microsoft.com> wrote in
message news:64F15382-14E5-42DD-A204-4FD8B3B26EC9@microsoft.com...
[quoted text, click to view]

DC
11/30/2005 6:00:54 PM
to handle these invalid cases, you can introduce special handling.
Example:
http://cheeso.members.winisp.net/srcview.aspx?dir=xml-serialization&file=XsiNilDate.cs

-D

--
-Dino
D i n o . C h i e s a AT M i c r o s o f t . c o m



[quoted text, click to view]

AddThis Social Bookmark Button