0

In my project I want to read a Large xml file which contains 20,000 records or more. what is the best of reading this xml file.

  1. Load xml into a dataset and loop through dataset and update the database
  2. Create xml object(serialize ) and loop through each object and update the database?

I appreciate if you could guide me on this and let me know if there is third other way to do this.

Nelson
  • 49,283
  • 8
  • 68
  • 81
Henry
  • 847
  • 6
  • 24
  • 53

1 Answers1

4

Try it. Number one rule of performance, always measure :-) Consider that both your options involves reading the entire XML into memory, which will take time and consume memory. A third option would be to use an XmlReader to read a single record at a time. I can only guess, but my bet is that XmlReader will be the fastest way.

driis
  • 161,458
  • 45
  • 265
  • 341
  • 1
    +1 to measure. I would not bet anything on which method would be faster if the amount of data is small enough to not hit any memory limits. About 20K of some sort of records does not sound too bad for me. And don't forget code that works is generally faster that retyping data manally after fast, but incorrect code :) – Alexei Levenkov Sep 15 '12 at 17:46