xpathdocument

Why do I get web exception when creating an XPathDocument?

我的未来我决定 提交于 2019-12-24 06:33:02
问题 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);

Why do I get web exception when creating an XPathDocument?

坚强是说给别人听的谎言 提交于 2019-12-24 06:32:03
问题 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);

Tell StructureMap to use a specific constructor

故事扮演 提交于 2019-12-10 12:27:58
问题 I have two services that require an XPathDocument . I want to be able to define named instances of XPathDocumnet to use in the configuration of the two services. I also want to be able to tell StuctureMap which constructor of XPathDocument to use. When I try to get an instance of XPathDocument it tells me that it can't find the plugged type for XmlReader . I want to use the constructor that requires a string uri for the xml file. I cannot seem to get this to work. Here is the StructureMap