1

I'd like to know what is the best practice. I'm exporting some data (tables) from my database to XML files so I can read my data from them. To export, I'm using DataTable.WriteXml (c#) Now to read, what is best? to import them into a dataset and use DataTable.Select to get the row I want or create an XPathDocument and use XPath to get the data? which performs best? I'm still learning xpath.

Androiderson
  • 16,865
  • 6
  • 62
  • 72

1 Answers1

1

Why not load the exported XML in using DataTable.ReadXml(fileName)? If you exported your table data using DataTable.WriteXml(file, XmlWriteMode.XmlSchema), then you can import it in to a new DataTable using ReadXml(file).

From an example in MSDN:

myOldTable.WriteXml(fileName, XmlWriteMode.WriteSchema);

DataTable newTable = new DataTable();
newTable.ReadXml(fileName);

If that's the case, I don't see where you'd need XPath. If I'm misunderstanding your question, please let me know and I'll update accordingly.

I hope this helps.

David Hoerster
  • 28,421
  • 8
  • 67
  • 102
  • Good, bacause that's what I'm doing already, I just wanted to know if I should use xpath instead since I'm working with XML's. But if that's not the case, even better! Thanks for your help. – Androiderson Aug 08 '11 at 12:54