i am parsing a big xml file (1 MB) in my WP7 App. The file is part of the project,
so its not loaded through the web. Unfortnuately it takes very long, ca. 3 seconds, to
get the content i need. I have read, that the problem is the xml serialization, and its
better to go for a binary serialization.
But i have my xml file now, is there any possibility to change the format or something
of my xml file, so that the parsing will go faster? I have split it in many parts already,
but its not significant faster.
1 megabyte isn’t particularly big.
A binary format will be more compact and faster, especially if you write your own rather than using the .net serialisation support, which adds a lot of overhead to the data.
If you want to stick with xml, you can usually improve performance significantly by using a brief, compact format:
Profile and optimise your loading code – you may find bottlenecks that are nothing to do with xml. You may be able to defer some work, or do some data conversion processing on another thread, but beware of introducing big complexity for small gains.
Finally, try different approaches – XmlDocument rather than XmlReader, or a different library, or pre-loading the data into a MemoryStream. You may find improvements can be made there too.
Or just tell your boss it’s because you don’t have an eight core xeon with a terabyte of fast ssds… 🙂