【发布时间】:2014-01-30 21:54:13
【问题描述】:
我有一个 xml 文件,我需要能够在列表或数组中对其进行排序
XML:
<Restaurant>
<name>test</name>
<location>test</location>
</Restaurant>
<Restaurant>
<name>test2</name>
<location>test2</location>
</Restaurant>
所有餐厅都将具有相同数量的字段和相同的字段名称,但给定 xml 文件中 <Restaurant></Restaurant> 的数量是未知的。
换句话说,我需要一个数组或列表并且能够做到这一点:
String name = restaurantArray[0].name;
String location = restaurantArray[0].location;
虽然我显然不需要这种语法,但这是我想要完成的功能。
【问题讨论】:
-
您到底想在字符串数组中放入什么?餐厅名称?
标签: c# xml xml-parsing linq-to-xml xml-deserialization