我必須將一些xml反序列化爲使用xsd.exe從xsd文件生成的對象類。一切都很好,但我的對象中的一部分總是空的,我不知道爲什麼,因爲在XML它有數據。反序列化xml到類對象中的空元素
這是XML文件:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<jdf:root xmlns:jdf="http://www.tmp.com/jdf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<jdf:header>
<jdf:trace-id>string</jdf:trace-id>
<jdf:timestamp>string</jdf:timestamp>
<jdf:command>string</jdf:command>
<jdf:version>string</jdf:version>
</jdf:header>
<even:data xmlns:even="http://tmp.com/zzz/pivot/event">
<even:event xmlns:com="http://tmp.com/zzz/utils/components">
<even:eventId>3</even:eventId>
<even:distributorId>string</even:distributorId>
<even:distributionNetworkId>string</even:distributionNetworkId>
<even:typology>string</even:typology>
</even:event>
</even:data>
</jdf:root>
這是從XSD文件我的課:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.tmp.com/jdf")]
[System.Xml.Serialization.XmlRootAttribute("root", Namespace = "http://www.tmp.com/jdf", IsNullable = false)]
public partial class JdfRoot
{
private JdfHeader headerField;
private object dataField;
/// <uwagi/>
public JdfHeader header
{
get
{
return this.headerField;
}
set
{
this.headerField = value;
}
}
/// <uwagi/>
public object data
{
get
{
return this.dataField;
}
set
{
this.dataField = value;
}
}
}
/// <uwagi/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://mib.bnpp.com/cle/pivot/event")]
[System.Xml.Serialization.XmlRootAttribute("data", Namespace = "http://tmp.com/cle/pivot/event", IsNullable = false)]
public partial class T_data
{
private EventOut eventField;
/// <uwagi/>
public EventOut @event
{
get
{
return this.eventField;
}
set
{
this.eventField = value;
}
}
}
我離開只是因爲完整版我很長的最必要的部分。
哪部分總是空? – Lali
零件「data」爲空 – malymakar