I have a web service processing an HTTP request. The resulting document has a built-in DOCTYPE that indicates the .dtd file. I want to use the new XML Schema Validation file created to connect new devices to my service.
I can successfully ignore the verification that continues in the .dtd file, but the .dtd file must exist on my local hard drive. I want to delete these obsolete files and have not found a way.
Sample XML document that I am processing:
<?xml version="1.0" encoding="us-ascii" standalone="no"?> <!DOCTYPE SomeMessage SYSTEM "SomeMessage.dtd"> <SomeMessage>data</SomeMessage>
Function I use to open a document:
private void LoadXmlDoc(XmlTextReader myXmlTextReader) { XmlReaderSettings readerSettings = new XmlReaderSettings(); readerSettings.ValidationType = ValidationType.Schema; readerSettings.Schemas.Add(null, MyGoodSchemaFile); readerSettings.DtdProcessing = DtdProcessing.Ignore; readerSettings.XmlResolver = null;
Excluded:
System.IO.FileNotFoundException: Could not find file 'c: \ windows \ system32 \ inetsrv \ SomeMessage.dtd'.
File name: 'c: \ windows \ system32 \ inetsrv \ SomeMessage.dtd'
at System.IO .__ Error.WinIOError (Int32 errorCode, String maybeFullPath)
The contents of the SomeMessage.dtd file are not used - it is ignored as I wish. However, the dummy file "c: \ windows \ system32 \ inetsrv \ SomeMessage.dtd" must exist, otherwise an exception will be thrown.
I am running on Windows 7 using Visual Studio 2010 and .Net 4.0
How can I ignore the built-in .dtd and also not require the installation of a dummy .dtd file on my computer?
c # xml dtd
aaaa bbbb
source share