我有这个xml,我正在尝试反序列化为一个类,但我无法创建适当的类。 xml是:
<?xml version="1.0" encoding="ISO-8859-1"?>
<AnswersPP s="DSD" lst="11/22/2016 1:08:39 PM" n="1">
<Results xmlns:ssud="www.solacestar.ud>
<ssud:starlist>
<ssud:star id="4234234">
<span style="white-space: nowrap">#NOMA, MAJOR</span>
</<ssud:star>
<ssud:star id="2352234">
<span style="white-space: nowrap">#NOMA, MINOR</span>
</<ssud:star>
</ssud:starlist>
</Results>
<Error/>
</AnswersPP>
我拥有的是:
[XmlRoot("AnswersPP")]
public class AMDResponseDto
{
[XmlElement("Results")]
public Results Results { get; set; }
[XmlElement("Error")]
public Error Error { get; set; }
}
public class Results
{
[XmlElement("starlist")]
public StarList StarList { get; set; }
}
public class StarList
{
[XmlElement("star")]
public List<Star> Data { get; set; }
}
public class Star
{
[XmlAttribute("id")]
public string Id { get; set; }
}
我知道这是绊倒我的命名空间,但我尝试过的任何东西都没有。有谁知道我需要做什么?
答案 0 :(得分:0)
只需在XMLAttribute和XmlElement注释中添加Namespace即可。