0
我有一个XML像下面C#反序列化对象
string input =
@"<g1:Person xmlns:g1=""http://api.google.com/staticInfo/"">
<g1:Id>005008</g1:Id>
<g1:Infolist>
<g1:Info><g1:Title>a</g1:Title></g1:Info>
<g1:Info<g1:Title>b</g1:Title></g1:Info>
<g1:Info><g1:Title>c</g1:Title></g1:Info>
<g1:overview>there are three chaters.</g1:overview>
</g1:Infolist>
<g1:age>23</g1:age>
</g1:Person>";
我定义对象,但我不知道放在哪里/人/ Infolist /概述。这个属性如何定义。在哪里放。
[XmlRoot(ElementName = "Person", Namespace = "http://api.google.com/staticInfo/")]
public class Person
{
public int Id { get; set; }
public int age { get; set; }
[XmlElement(ElementName = "Infolist", Namespace = "http://api.google.com/staticInfo/")]
public List<Info> Infolist {get;set; }
}
public class Info
{
public int Title { get; set; }
}
自动生成?什么是工具,man?我手动定义许多类 – user1682718
xsd.exe是工具。你可以使用它的输出来帮助你手动定义你的类。否则别人也许会回答你的问题太好了...祝你好运 –
wow.awesome男人,谢谢你,发布给我更多的知识 – user1682718