我有描述连接的XML文件重复的结构,即读取XML文件使用C#
<?xml version="1.0" encoding="utf-8"?>
<connections>
<connection name="Local server remote">
<ip>192.168.0.7 </ip>
<port>23 </port>
<description>
Remote controlling of that nice & neat box under the table.
</description>
</connection>
<connection name="Far, far away server HTTP access">
<ip>77.32.57.144 </ip>
<port>8080 </port>
<description>
A legend tells of a far, far away country of Russia, and of a server somewhere inside this mysterious country.
</description>
</connection>
</connections>
有一种简单的方法来解析XML文件转换成像一个类的对象:
class Connection {
public string Name;
public string IP;
public int Port;
public string Description;
}
?
我建议你看看这个StackOverflow的答案:http://stackoverflow.com/questions/608110/is-it-possible-to-deserialize-xml-into-listt因为它正在做你正在做的事情。 – Adrian
@阿德里安,谢谢 –