What is the correct format to use for Date/Time in an XML file

前端 未结 5 1104
温柔的废话
温柔的废话 2020-11-27 15:50

What format do I use for Date/Time when writing to an XML file using .NET? Do I simply use DateTime.ToString(), or do I have to use a specific format?

5条回答
  •  孤街浪徒
    2020-11-27 16:21

    What does the DTD have to say?

    If the XML file is for communicating with other existing software (e.g., SOAP), then check that software for what it expects.

    If the XML file is for serialisation or communication with non-existing software (e.g., the one you're writing), you can define it. In which case, I'd suggest something that is both easy to parse in your language(s) of choice, and easy to read for humans. e.g., if your language (whether VB.NET or C#.NET or whatever) allows you to parse ISO dates (YYYY-MM-DD) easily, that's the one I'd suggest.

提交回复
热议问题