我搞不清楚情况,我有一个Xml床单 看起来像这个
<root>
<list id="1" title="One">
<word>TEST1</word>
<word>TEST2</word>
<word>TEST3</word>
<word>TEST4</word>
<word>TEST5</word>
<word>TEST6</word>
</list>
<list id="2" title="Two">
<word>TEST1</word>
<word>TEST2</word>
<word>TEST3</word>
<word>TEST4</word>
<word>TEST5</word>
<word>TEST6</word>
</list>
</root>
我试图把它连成
public class Items
{
[XmlAttribute("id")]
public string ID { get; set; }
[XmlAttribute("title")]
public string Title { get; set; }
//I don t know what to do for this
[Xml... something]
public list<string> Words { get; set; }
}
//I don t this this is right either
[XmlRoot("root")]
public class Lists
{
[XmlArray("list")]
[XmlArrayItem("word")]
public List<Items> Get { get; set; }
}
//Deserialize XML to Lists Class
using (Stream s = File.OpenRead("myfile.xml"))
{
Lists myLists = (Lists) new XmlSerializer(typeof (Lists)).Deserialize(s);
}
我真的是新来的, 与XML和XML 串连, 任何帮助都会非常感激