System.Xml.XmlDocument, what's the best way to cache the DTD of an external dependency?

I am loading valid XHTML into an XmlDocument but it takes 2 seconds to load. I found that if I drop the DTD it is instant, but then I have to replace & nbsp; to & # 160 ;, etc. The number of HTML entities declared is large, so I feel like the DTD should be loaded. So what's the easiest way to preload a DTD with minimal manual labor? Perhaps if I could, say, put the DTD in an assembly as a resource file and insert it into ...? Any suggestions?

+1


a source to share


1 answer


I found a technique here by implementing an abstract XmlResolver class and setting it to the XmlDocument property of the XmlResolver. An abstract implementation of the class returns a MemoryStream object for the requested URL, which contains a DTD or any other resource that would normally be loaded over HTTP.



http://www.codeproject.com/KB/XML/HTML2XHTML.aspx?display=Print

+1


a source







All Articles