views:

41

answers:

1

Hi all,

I have multiple XML files that I need to parse. Problem is that I only need some data in the last couple of lines.

I currently use XMLTextReader and reader.ReadToFollowing("DATANEEDED"); but it is still too slow. Does anyone know if I can 'tail' an XML file and read from there? (taking into account the tail would not be a valid XML file) or any other ways to retrieve the last few nodes in the XML without parsing through the entire XML file?

I am using .NET 2.0 so no in-built linq :(

Thanks

A: 

XmlDocument is a better choice. Within it use xPath queries. I guess XmlDocument take cares about performance automatically.

afsharm
You guess wrong. using XMLDocument will be orders of magnitude slower than XMLTextReader, especially for large files.
Binary Worrier
That's what I read too. XMLTextReader seems to be the fastest.
xt_20
XmlDocument is a lot slower, see for example http://www.nearinfinity.com/blogs/joe_ferner/performance_linq_to_sql_vs.html
Mauricio Scheffer