473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

XMLDocument serilization date format

RJA
Hiyas,

Using VS .net 2003.

Setting up a Webservice that accepts 3rd party vendor designed XML requests
and returns a filled XMLDocument with response data.
Vendor XSDs were serialize into class objects to be used in the program.

EX: Used xsd.exe to turn VendorA_Request.XSD into VendorA_Request.cs
EX: Used xsd.exe to turn VendorA_Response.XSD into VendorA_Response.cs
etc etc..

Program logic is like this:
Webservice accepts an XML request as a string.
Deserialize the string into its appropriate request class object.
Run the request class through business logic and produce result class.
Serialize the result class into response XML document object to be returned.
Webservice returns the XMLDocument.

Problem:
Vendor XML schema verification is failing because the return date format are
incorrect.

Correct date format is
date1="2006-01-01T00:00:00"
My return XML date format is
date1="2006-01-01T00:00:00.0000000-05:00"

Because the XMLDocument object being returned is generated by serializing a
class object, I'm not sure how to get the correct formatting.

After hours of googling:
http://support.microsoft.com/default...b;en-us;811767

But that solution is assuming modification of the date format upon output.
Since the XMLDocument is not being outputted but is returning to the caller,
the solution does not work.

How should I go about correcting the date formatting inside the XMLDocument?
Modify the class datatype from DateTime?
Modify the serilization method to override the default datetime format?
Loop through the XMLDocument and update the date formatting before returning
it?
Use XSLT to produce a new XMLDocument with the correct format?

Any help will be greatly appreciated.

-RJA
Apr 7 '06 #1
3 5955
>Modify the serilization method to override the default datetime format?
If this is possible i would like to see it - But I dont think so think

NB: You can relate The XSD type xsd:date, xsd:dateTime to the CLR type
System.DateTime

<XmlElement(DataType:="date", ElementName:="date1")> _
Public Property dt() As DateTime
...
or
<XmlElement(DataType:="dateTime", ElementName:="date1")> _
Public Property dt() As DateTime
...
but neither of these are in the format you want.
Modify the class datatype from DateTime?

to say String - yes a possible solution

==============================================
Private _dt As DateTime

<XmlElement(ElementName:="date1")> _
Public Property dt() As String
Get
Return _dt.ToString("yyyy-MM-ddThh:mm:ss")
End Get
Set(ByVal Value As String)
_dt = Value
End Set
End Property
==============================================
Dickster

Apr 11 '06 #2


RJA wrote:

Problem:
Vendor XML schema verification is failing because the return date format are
incorrect.

Correct date format is
date1="2006-01-01T00:00:00"
That is not an XSD date, rather a dateTime.
My return XML date format is
date1="2006-01-01T00:00:00.0000000-05:00"


That is a dateTime too, with some milliseconds and a time zone
information which is allowed.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 11 '06 #3
> Loop through the XMLDocument and update the date formatting before returning
it?

You could update the .InnerXml property of each <date1> node but this
feels like a less than slick solution.

However not to rule it out - Perhaps you could write a method which you
apply to each of the relevant nodes

i.e using SelectSingleNode or SelectNodes on the XmlDocument assign the
value of original .InnerXml of each <date1> node to a DateTime Object
and use the .ToString("yyyy-MM-ddThh:mm:ss") to return the result and
reassign to .InnerXml

There's probably better formatting solution but I think this would do
the job.

Dickster

Apr 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: George W. | last post by:
Okay, I'm a C#/XML newbie, and I've been wrestling with this for a while now, checked dotnet sites, articles, MSDN Library, etc. and haven't been able to determine why this is happening. I have...
4
by: Robert Rossney | last post by:
I'm trying to send and receive XmlDocument objects using the System.Messaging.dll functions. The code I've written follows, as best I can tell, the methodology used in the sample code for the...
13
by: Matthew Wieder | last post by:
In my C# application, I have class which has method that opens an XML document, modifies it and saves it out. I run that method for several different XML documents. What I've found is that the...
6
by: amethyste | last post by:
hello, This is my sample (simplified): public class Binom { public string _Value;
3
by: Stephan Schlicker | last post by:
Hi everyone I have a serious problem with the serilization of an user-defined object in C#. I would like to serialize an object of class D which inherits from class C. Class C as well as class D...
4
by: MattBell | last post by:
I've tried to search for an answer to this without much success, and I think it's probably a common thing to do: I have a web service I want to accept an XmlDocument as an argument which conforms...
5
by: Alan Silver | last post by:
Hello, Sorry if this is an obvious question, but I'm not very familiar with using XmlDocument, and I am struggling with a really simple task. I couldn't find anything clear that explained what I...
7
by: Mike9900 | last post by:
If you do .NET Remoting and Binary Serilization with DataSet it does not work. If you set the Serialization type to Binary on DataSet, it does not seralize it correctly on windows xp. To do this...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... We've got a lot of places in our code where we read relatively small xml user preference blocks. Currently that's creating a new XmlDocument in every spot. I was thinking we might see...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.