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,847
  • 2
  • 32
  • 42
Yanshof
  • 9,659
  • 21
  • 95
  • 195

2 Answers2

4

You can use LinqToXml

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

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

iAdjunct
  • 2,739
  • 1
  • 18
  • 27