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?
In dataset you can read xml file
Following are lines of code to read XML file in DataSet
In the past, I have used an
XmlReader
and had no difficulties.MSDN Documentation: http://msdn.microsoft.com/en-us/library/system.xml.xmlreader(v=vs.110).aspx
It is very straightforward and the documentation is pretty well written. A quick demonstration of how to use it:
Use LINQ to XML, Include
using System.Xml.Linq;
Output would be:
This will give you a
string[]
.