我的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.
知道要改变什么吗?