Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用xml中的空日期反序列化_C#_Xml_Serialization - Fatal编程技术网

C# 用xml中的空日期反序列化

C# 用xml中的空日期反序列化,c#,xml,serialization,C#,Xml,Serialization,我最近对xsd进行了排序,以允许xml数据在日期字段中有空字符串。我使用simpleType和union来实现这一点: <xsd:simpleType name="EmptyDate"> <xsd:union memberTypes="xsd:date emptystring" /> </xsd:simpleType> <xsd:simpleType name="emptystring"> <xsd:restriction base

我最近对xsd进行了排序,以允许xml数据在日期字段中有空字符串。我使用simpleType和union来实现这一点:

<xsd:simpleType name="EmptyDate">
  <xsd:union memberTypes="xsd:date emptystring" />
</xsd:simpleType>

<xsd:simpleType name="emptystring">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="" />
  </xsd:restriction>
</xsd:simpleType>
当我调试代码时,它在反序列化代码的最后一行抛出了一个错误


有没有办法操纵c#代码,使其允许通过空日期传递

可能是的副本?我已经研究了那篇文章,但没有提供解决方案。我尝试了他们在那里的东西,但它仍然出现了同样的错误,而不是支持一个空字符串用于<代码> DATEIMECT//>,考虑允许它是空的:@ dBC,而这是一个很好的解决方案,不幸的是,我从客户端得到的数据是大约120000行的XML数据。所有空的日期字段都将表示为,因此本质上是一个空字符串。浏览整个文档并将值更改为lol会非常麻烦。当我更改xsd时,我忘记了更新类。我现在觉得自己很傻,哈哈。但我一更新类,文件就开始反序列化。如果你没有告诉我提供一个示例类,我甚至不会意识到。谢谢:)
xml_path = xml_dir + file_name;
XmlSerializer x = new XmlSerializer(typeof(Families));
Families fam;
using (XmlReader read = XmlReader.Create(xml_path))
{
    fam = (Families)x.Deserialize(read);
}