Load XML file into DataTable (not from a Database)

I'm looking into changing my application to load its xml format data files into DataTables (and a DataSet?) instead of deserializing them into classes. I can generate a dataset using xsd.exe, but I'm not having any luck finding any examples showing how to use it.

My Google searches have been hopelessly clogged with examples using xsd files as an intermediary in accessing database tables. Since my apps saving data files instead of querying a DB these aren't of any use to me.

Upvotes: 3

Views: 8171

Answers (2)

Webleeuw
Webleeuw

Reputation: 7282

Is manually filling the schema and table an option?

DataTable table = new DataTable();
table.ReadXmlSchema(xmlReader);
table.ReadXml(xmlReader);

Upvotes: 3

Saar
Saar

Reputation: 8474

Try out with. May be you need to format your xml.

    DataSet ds = new DataSet();
    ds.ReadXml("xml file path");

Upvotes: 6

Related Questions