没有root反序列化的Xml

时间:2015-06-19 12:56:35

标签: c# .net xml deserialization

我的XML看起来像

 <root>
<LogEntry>
    <Data1> </Data1>
    <Data2> </Data2>
</LogEntry>
<LogEntry>
    <Data1> </Data1>
    <Data2> </Data2>
</LogEntry>
 </root>

我的班级看起来像

[XmlRoot("Root")]
public class LogEntries
{
    [XmlElement("LogEntry")]
    public List<ClientLogEntry> Entries { get; set; }

    public ClientLogEntries()
    {
        Entries = new List<ClientLogEntry>();
    }
}

其中ClientLogEntry具有LogEntry节点内的属性。

var serializer = new XmlSerializer(typeof(LogEntries));
var entries= (LogEntries)serializer.Deserialize(this.TaskDefinition.XmlStream);

它说           <root xmlns=''> was not expected.知道要改变什么吗?

0 个答案:

没有答案