this is the xml
这是xml
<Basic>
<Results>
<Result>a1</Result>
<Result>a2</Result>
<Result>a3</Result>
</Results>
</Basic>
I need to read this xml file and create a list that will contain
我需要读取这个xml文件并创建一个包含的列表。
list[0] = a1
list[1] = a2
list[2] = a3
what is the simple and fast way to do it ?
简单快速的方法是什么?
2 个解决方案
#1
4
You can use LinqToXml
您可以使用LinqToXml
var list = XDocument.Load(filename)
.Descendants("Result")
.Select(x => (string)x)
.ToList();
#2
1
With an XML reader and a codec to convert the DOM tree to a list.
使用XML阅读器和编解码器将DOM树转换为列表。
#1
4
You can use LinqToXml
您可以使用LinqToXml
var list = XDocument.Load(filename)
.Descendants("Result")
.Select(x => (string)x)
.ToList();
#2
1
With an XML reader and a codec to convert the DOM tree to a list.
使用XML阅读器和编解码器将DOM树转换为列表。