1

this is the 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

list[0] = a1   
list[1] = a2   
list[2] = a3   

what is the simple and fast way to do it ?

Kirby
  • 2,401
  • 1
  • 27
  • 40
Yanshof
  • 9,297
  • 18
  • 86
  • 178

2 Answers2

4

You can use LinqToXml

var list = XDocument.Load(filename)
           .Descendants("Result")
           .Select(x => (string)x)
           .ToList();
Eser
  • 12,031
  • 1
  • 19
  • 32
1

With an XML reader and a codec to convert the DOM tree to a list.

iAdjunct
  • 2,331
  • 15
  • 23