我有描述連接的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
@阿德里安,謝謝 –