Why do I get web exception when creating an XPathDocument?
问题 Creating an XPathDocument with referenced DTD sometimes throws a web exception. Why? 回答1: You can write a custom XmlUrlResolver and then ignore the remote DTD. Also, I believe you can set use XmlResolver = null on the XmlTextReader. 回答2: for those interested I've found a workaround to disable the dtd check XmlReaderSettings settings = new XmlReaderSettings(); settings.XmlResolver = null; settings.ProhibitDtd = false; var xmlReader = XmlTextReader.Create(new StringReader(xmlString),settings);