How to read XML file in c#?
c#, linq, linq-to-xml, xml
Solution
var xdoc = XDocument.Load(PATH_TO_FILE);
var companies = xdoc.Descendants("Company").Select(c => (string)c).ToArray();
This will give you a `string[]`.
Problem
I have following XML file, i want to know best way to read this XML file ``` <MyFile> <Companies> <Company>123</Company> <Company>456</Company> <Company>789</Company> </Companies> </MyFile> ``` As an output i need collection of values like "123,456,789" or it could be array of string[] Can we use Linq to xml? How?