473,856 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLDocument serilization date format


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_Respons e.XSD into VendorA_Respons e.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.

Vendor XML schema verification is failing because the return date format are

Correct date format is
My return XML date format is
date1="2006-01-01T00:00:00.000 0000-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:

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
Use XSLT to produce a new XMLDocument with the correct format?

Any help will be greatly appreciated.

Apr 7 '06 #1
3 6002
>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

<XmlElement(Dat aType:="date", ElementName:="d ate1")> _
Public Property dt() As DateTime
<XmlElement(Dat aType:="dateTim e", ElementName:="d ate1")> _
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(Ele mentName:="date 1")> _
Public Property dt() As String
Return _dt.ToString("y yyy-MM-ddThh:mm:ss")
End Get
Set(ByVal Value As String)
_dt = Value
End Set
End Property
=============== =============== =============== =

Apr 11 '06 #2

RJA wrote:

Vendor XML schema verification is failing because the return date format are

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

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


Martin Honnen --- MVP XML
Apr 11 '06 #3
> Loop through the XMLDocument and update the date formatting before returning

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 SelectSingleNod e 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.


Apr 11 '06 #4

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

Similar topics

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 an xml file that I am loading into an XmlDocument and then trying to add a child element to the root element. I keep getting: System.ArgumentException: The reference node is not a child of this node. This occurs at the line where I'm using...
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 XmlMessageFormatter class. But it isn't working -- specifically, receiving isn't working. What am I doing wrong here? I begin by creating a MessageQueue object and setting up its XmlMessageFormatter to handle XmlDocument objects: System.Type...
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 Load emthod on the MXLDocument isntance loads the document into memory (as it should) but I have no way of releaseing that memory throughout the application, and I run out of memory. The documents I'm loading are abou 10 MB in size, and I run out...
by: amethyste | last post by:
hello, This is my sample (simplified): public class Binom { public string _Value;
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 are marked with the compiler-attribute (see also code-snippet at the end of the message). It is no problem to serialize a instance of class C, but I got the following error-message if I try to serialize a instance of class D: An unhandled...
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 to a specific XSD that is defined. Right now when I declare XmlDocument as my argument, it puts the old xml:any type in. How do I change that to reflect the XSD that I'm looking for? Thanks for any Help!
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 want to do. Suppose I have an XmlDocument like this... <books> <number>3</number>
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 set the serilization to Binary and use it in remoting on Windows XP. Is there a way around this? -- Mike
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 some speed improvements by having one, central XmlDocument and using doc.ReadNode() to process all of the fragments. Other than pumping up the NameTable with a mish-mash of different node names and namespaces, are there any other implications I'm...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.