我需要获取XML的以下部分:
<TestInfo>
//.....
<Screenings>
<UnitCodes>
<UnitCode></UnitCode> <!-- Can be repeated -->
</UnitCodes>
</Screenings>
</TestInfo>
我有以下课程:
public class TestInfo
{
//....
[XmlArray("Screenings")]
[XmlArrayItem("UnitCodes", typeof(Screening))]
public List<Screening> Screenings { get; set; }
}
public class Screening
{
[XmlArrayItem("UnitCode", typeof(string))]
public List<string> UnitCodes { get; set; }
}
但它会生成:
<TestInfo>
//.....
<Screenings>
<UnitCodes>
<UnitCodes>
<UnitCode>number</UnitCode>
</UnitCodes>
</UnitCodes>
</Screenings>
</TestInfo>
如何删除不必要的(两次)UnitCodes
节点?
谢谢!