-
May 20th, 2009, 11:49 AM
#1
Fast XML
Assuming I have this simple XML:
<book>
<Author>person</Author>
<Title>My Title</Title>
</book>
<book>
<Author>person2</Author>
<Title>My Title 2</Title>
</book>
etc...
What is the fastest way to parse this file and buffer lists of authors and titles assuming there is a very large amount of entries in the file?
-
May 20th, 2009, 02:22 PM
#2
Re: Fast XML
Why would you want to parse the file yourself?
-
May 20th, 2009, 02:31 PM
#3
Re: Fast XML
By parsing if you mean reading the XML file then try Dataset's ReadXML method.
-
May 20th, 2009, 04:24 PM
#4
Re: Fast XML
I am simply looking for the computationally-fastest method of buffering this information. This could be manually parsing or using any of the built in XML reading methods in C#, I just want to know which would be the best choice for huge datasets.
-
May 20th, 2009, 04:47 PM
#5
Re: Fast XML
Originally Posted by tj1111
I am simply looking for the computationally-fastest method of buffering this information. This could be manually parsing or using any of the built in XML reading methods in C#, I just want to know which would be the best choice for huge datasets.
Well, you will have to measure before you can know anything. I would try it first with the built in parsing classes and see if that won't do what you need. There is no sense in rolling your own XML parser (Chok-full of bugs and inefficiencies) if the built in stuff works just fine. Using compiled xml node iterators can be faster than the DOM (XmlDocument) model, but again, try the easy way first,.
-
May 20th, 2009, 05:25 PM
#6
Re: Fast XML
XmlReader if the input file is huge. Otherwise XmlDocument would be just fine. The problem with XmlDocument is that it uses a chunk of memory because it essentially splits the input into a bunch of strings and keeps them all in memory. XmlReader is a forward-only reader and doesn't keep excess stuff in memory so if all you want to do is read the data once (and not query again) XmlReader is your friend.
www.monotorrent.com For all your .NET bittorrent needs
NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|