Serializing from XML with remote DTD



Hey,

I have an XML file which I am serializing into a class using the
following code:
//
XmlSerializer s = new XmlSerializer(typeof(edition));
StreamReader r = new StreamReader(ConfigFileName);
XmlReaderSettings xrs = new XmlReaderSettings();
xrs.ProhibitDtd = false;
xrs.ValidationType = ValidationType.None;
XmlReader xr = XmlReader.Create(r, xrs);
currentEdition = s.Deserialize(xr) as edition;
//
So this works dandy when I'm connected to the Internet. But
unfortunately, the XML file has a dtd in it that points to a remote
site. So when I yank the cat5, I get an error (An error has occurred
while opening external DTD '...: The remote name could not be
resolved)

Obviously, setting 'ProhibitDtd' to true causes an exception as well.

So is there a way to serialize the XML file while ignoring the DTD? I
mean, it's not trying to validate it (ValidationType is None), so why
does it need the DTD? It's just mapping tag names to class names and
attributes to fields. Is there a way to do this, or am I going to have
to cache the DTD locally? -_-

Thanks,
Nathan

.



Relevant Pages

  • Re: Confused About Validation
    ... DTDs have to be included or referred from an XML file. ... setting the validation type to DTD. ... > saying that Doctype is not defined. ... then use it to load / validate the xml files? ...
    (microsoft.public.dotnet.xml)
  • Re: Specifying a DTD for a DOMDocument
    ... against a DTD if load the XML file. ... Seems that the validate() function only works when loading xml files. ...
    (comp.lang.php)
  • validating xml against DTD
    ... I am using the following code to validate an xml file ... against a DTD. ... I force the requirement to declare the DTD in the XML ... Private Function validate() As Boolean ...
    (microsoft.public.dotnet.languages.vb)
  • how to ignore DTD and NOT download it when ValidationType=none?
    ... I'm trying to load and parse an xml file with XmlReader and have it ... ValidationType.None" it STILL downloads the DTD even though it doesn't ... Why would it download it if it's not going to validate against it? ...
    (microsoft.public.dotnet.xml)
  • Re: Convert flat file to XML document
    ... >I am a newbee and have a comma seperated flat-file and a DTD. ... >XML file as per the the definition in the DTD. ... As required add extra processing to your program so that you can ... The ultimate truth is that there is no ultimate truth ...
    (microsoft.public.dotnet.languages.csharp)