views:

91

answers:

2

I have a 150MB XML file which used asDB in my project. Currently I'm using XMLReader to read content from it.

I want to know it is better to use XMLReader or LinqToXML for this scenario.

Note that I'm searching for an item in this xmland display search result, soitcan be take along or just a moment.

+2  A: 

If you want performance use XMLReader. It doesn't read the whole file and build the DOM tree in memory. It instead, reads the file from disk and gives you back each node it finds on the way.

With a quick google search I found a performance comparison of XMLReader, LinqToXML and XDocument.Load.

http://www.nearinfinity.com/blogs/joe_ferner/performance_linq_to_sql_vs.html

Tebari
+1  A: 

Write a few benchmark tests to establish exactly what the situation is for you, and take it from there... Linq2XML introduces a lot of flexibility...

Martin Milan