views:

48

answers:

1

I have wrote a WPF application that reads a list of movies from a XML file at a network location. When I started investigating the slow start-up it turned out that XmlSerializer has a lot overhead.

I have now used sgen to build the assemblies before I publish the project but I am now looking into a better solution. I have looked at the BinaryFormatter class but the XML file is created by a PHP script running on the Linux server.

Would I be better to use an XML file reader and loop through the file myself or is there a better option? I am aiming for speed so any suggestions to replace my XmlSerializer are welcome.

Here is the code for de-serializing the the file.

    public List<Movie> DeSerializeXmlObject(string filename)
    {
        List<Movie> movies;
        Stream stream = File.Open(filename, FileMode.Open);
        XmlSerializer s = new XmlSerializer(typeof(List<Movie>));
        movies = (List<Movie>)s.Deserialize(stream);
        stream.Close();
        return movies;
    }

I couldn't figure out how to attach files so I pasted the XML file onto pastebin. http://pastebin.com/Rxsy0R3c Thanks Ben

A: 

There is high possibility you are doing something wrong. Parsing even 1MB xml would take no more than 1 second. Would you kindly post your serialization and deserialization code with XML file you are trying to parse?

Edit: Sorry, I think I cant help you. Your code and file looks alright. Only option I see now is lazy load this file in background worker and then set movies back in GUI thread.

Euphoric
I have updated my question to show the code. I have also pasted the XML file to pastebin.
Ben
I lazy loaded the file, it seemed that the main part of the delay was bringing the file over the network.
Ben