1

I'm trying to deserialize XML from an external service, so I have no control over the output XML I receive.

The service's XML is a little strange. It doesn't specify a schema, it references itself. For example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE response>
<response>
 // blah blah
</response>

I can use VS's built in tools to create an XSD file for it, but when deserializing, is it possible to specify a local XSD file? Instead of using the non-existent one in the DOCTYPE tag?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Jason La
  • 1,051
  • 4
  • 12
  • 25
  • What problem are you having? What doesn't work? – John Saunders Jan 19 '11 at 00:51
  • Sorry, John. The error I'm getting is: "For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method." – Jason La Jan 19 '11 at 02:06

1 Answers1

2

You might need to specify to not use an XmlResolver when loading the XML document. See Ignore DOCTYPE .dtd, but .dtd file must still exist

You can easily specify the .xsd file. Use an XmlReaderSettings object when you load the document. Note that if your program is a web service, your .xsd might need to reside under the Windows directory. For a hint at it, including pain on 64 bit Windows, see MSI Installer, 64 bit OS, write to \windows\system32\inetsrv folder

Community
  • 1
  • 1
aaaa bbbb
  • 3,003
  • 2
  • 23
  • 23
  • Thanks, aaaa bbbb (great name). I had previous specified DtdProcessing = DtdProcessing.Ignore, but I didn't set the resolver to null. With that, my deserialization is working. – Jason La Jan 19 '11 at 18:12