我正在使用XmlSerializer.Serialize
并且XmlSerializer.Deserialize
我有一个类 MetricResult:
public class Metricresult
{
public string metric;
public string newvalue;
public string deltavalue;
}
我正在计算一些将存储在的结果:
List<Metricresult> metricresults = new List<Metricresult>();
我成功将此列表更改为 xml 文件,在另一个项目中我需要反序列化此列表,但抛出异常:
there-is-an-error-in-xml-document-0-0-during-deserialization
xml文件
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfMetricresult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Metricresult>
<metric>numberofdeclaration</metric>
<newvalue>0</newvalue>
<deltavalue>0</deltavalue>
</Metricresult>
<Metricresult>
<metric>numberofdeclaration</metric>
<newvalue>0</newvalue>
<deltavalue>0</deltavalue>
</Metricresult>
<Metricresult>
<metric>numberofdeclaration</metric>
<newvalue>0</newvalue>
<deltavalue>0</deltavalue>
</Metricresult>
<Metricresult>
<metric>numberofdeclaration</metric>
<newvalue>0</newvalue>
<deltavalue>0</deltavalue>
</Metricresult>
<Metricresult>
<metric>numberofdeclaration</metric>
<newvalue>0</newvalue>
<deltavalue>0</deltavalue>
</Metricresult>
<Metricresult>
<metric>numberofdeclaration</metric>
<newvalue>0</newvalue>
<deltavalue>0</deltavalue>
</Metricresult>
</ArrayOfMetricresult>