Experiencing Delay in Loading XML Documents

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
T

Terry Olsen

I'm writing a program that imports sometimes large XML files. I'm
duplicating another program that does this. I have found that the other
program will import & display the data almost instantly, no matter how large
the XML file. However, when using the XMLDocument.Load function, it takes
anywhere from 15-30-45 seconds before I see any data.

I've done some tests and it's the initial loading of the XML document that
takes all the time. Once loaded, the XMLDocument is pretty responsive to
selecting nodes and reading text. I've tried switching from using the
XMLDocument to using the XMLTextReader but I still have the same delay on
loading.

Is there a quicker method for stepping through an XML document sequentially?
Can I turn off XML Verification?

Thanks.
 
I'm writing a program that imports sometimes large XML files. I'm
duplicating another program that does this. I have found that the
other program will import & display the data almost instantly, no
matter how large the XML file. However, when using the
XMLDocument.Load function, it takes anywhere from 15-30-45 seconds
before I see any data.

I've done some tests and it's the initial loading of the XML document
that takes all the time. Once loaded, the XMLDocument is pretty
responsive to selecting nodes and reading text. I've tried switching
from using the XMLDocument to using the XMLTextReader but I still have
the same delay on loading.


How large are these files?

Perhaps the other program is loading the data in chunks?
 
Anywhere from a few K up to 3MB. Even with the small ones, it takes longer
than I think it should. I just loaded one that is 357kb. It took 20 seconds
for the XMLDocument.Load method to complete.
 
Terry said:
I'm writing a program that imports sometimes large XML files. I'm
duplicating another program that does this. I have found that the other
program will import & display the data almost instantly, no matter how large
the XML file. However, when using the XMLDocument.Load function, it takes
anywhere from 15-30-45 seconds before I see any data.

I've done some tests and it's the initial loading of the XML document that
takes all the time. Once loaded, the XMLDocument is pretty responsive to
selecting nodes and reading text. I've tried switching from using the
XMLDocument to using the XMLTextReader but I still have the same delay on
loading.

Is there a quicker method for stepping through an XML document sequentially?
Can I turn off XML Verification?

Does the XML document reference any resources on the web? It sounds to
me as if you might see that "delay" as the parser has to fetch a
resource (e.g. a DTD) from a HTTP server. Just a guess obviously. And
with .NET 2.0 and normal settings DTDs should cause an error so the
guess might be wrong.
 
Do you see the same delay using the XmlReader class? You stated that
you did when using XmlTextReader, but I would give the XmlReader class
a try. For very large XML documents, I definitely would not use the
XmlDocument class.
 
Back
Top