【发布时间】:2015-12-31 01:15:32
【问题描述】:
我有一个描述连接的 XML 文件,即
<?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 答案:stackoverflow.com/questions/608110/…,因为它正在做你想做的事情。
标签: c# xml oop parsing deserialization