Hi,
I got a XML schema for which I used xsd.exe to generate a Class FooClass
.
I am receiving xml requests from host which I get them from a directory and use the XmlSerializer.Deserialize()
to get a Instance of my FooClass
.
Well, this worked till now perfectly and it still does, but suddenly I started to get XML files which are larger (about 300KB) and the time which it takes to Deserialize()
is not acceptable! Loading the same XML file with XMLTextReader()
takes milliseconds and the time to deserialize is about 1 minute and 30 seconds!
So I thought I'll use the XMLReader to read the XML file and build FooClass
by myself!
But before I start to rework all my code, I would like to ask you if there is a way to use XmlSerializer.Deserialize()
which would be faster?
I am not sure if XMLSerializer Assembly would help me much here?
here is my code which will be called in a Loop for each file
using (MemoryStream ms = new MemoryStream(xmldata)
{
XmlSerializer sz = new XmlSerializer(typeof(FooClass));
foo = (FooClass)sz.Deserialize(ms);
}
Thanks in advance, AK