sams
sams

Reputation: 21

How to close xml file

XmlDataDocument xmlDocument = new XmlDataDocument();
xmlDocument.DataSet.ReadXml(@"E:\Projects\...\PlayerSubReport.rdlc");

I am reading xml file and set to a dataset. My requirement is how to close xml from reading.

Upvotes: 1

Views: 1725

Answers (2)

Bernd Linde
Bernd Linde

Reputation: 2152

You could also use the DataTable.ReadXml(string fileName) or DataSet.ReadXml(string fileName) methods to populate the DataTable/DataSet with your data, if your XML is in the same format as what your DataTable/DataSet is expecting.

Sample code as how you could call it:

TestingDataSet.TestingDTDataTable dt = new TestingDataSet.TestingDTDataTable();
dt.ReadXml(@"E:\Projects\...\PlayerSubReport.rdlc");

Upvotes: 1

Rahul Tripathi
Rahul Tripathi

Reputation: 172458

To start with XmlDataDocument class is now obsolete. The alternative is to use XMLDocument, but even then you need to rely on garbage collector to close your xml file since XmlDocument class does not implement IDisposable. Something like this:

nodes = null;
xml = null;
GC.Collect();

An alternative is to read the the data of XML using the XMLReader since it uses less memory.

Upvotes: 1

Related Questions