Can I specify an XML schema/xsd when deserializing?
I'm trying to deserialize XML from an external service, so I have no control ove开发者_StackOverflowr 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?
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
精彩评论