This is an error that has recently started to plague my rss feed parser. This morning four of my rss feeds started to throw this exception:
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.
The code used to work fine, but I believe there has been a change to these four specific rss feeds that is causing this issue. Something with the feed using DTD when it wasn't using one before or some sort of schema change that my SyndicationFeed is not being able to parse.
So I changed my code to
string url = RssFeed.AbsoluteUri;
XmlReaderSettings st = new XmlReaderSettings();
st.DtdProcessing = DtdProcessing.Parse;
st.ValidationType = ValidationType.DTD;
XmlReader reader = XmlReader.Create(url,st);
SyndicationFeed feed = SyndicationFeed.Load(reader);
reader.Close();
Then I started to receive this error:
The 'html' element is not declared.
in
System.Xml.XmlValidatingReaderImpl.ValidationEventHandling.System.Xml.IValidationEventHandling.SendEvent(Exception exception, XmlSeverityType severity) at System.Xml.Schema.BaseValidator.SendValidationEvent(String code, String arg) at System.Xml.Schema.DtdValidator.ProcessElement() at System.Xml.Schema.DtdValidator.ValidateElement() at System.Xml.Schema.DtdValidator.Validate() at System.Xml.XmlValidatingReaderImpl.ProcessCoreReaderEvent() at System.Xml.XmlValidatingReaderImpl.Read() at System.Xml.XmlReader.MoveToContent() at System.Xml.XmlReader.IsStartElement(String localname, String ns) at System.ServiceModel.Syndication.Atom10FeedFormatter.CanRead(XmlReader reader) at System.ServiceModel.Syndication.SyndicationFeed.Load[TSyndicationFeed](XmlReader reader) at System.ServiceModel.Syndication.SyndicationFeed.Load(XmlReader reader)
I have no idea where this 'html' element is coming from since neither the feed nor any visible dtd definition in the feed(http://jobs.huskyenergy.com/RSS) mentions it. I have also tried setting the Dtdprocessing
to DtdProcessing.ignore
however that results in the following error:
The element with name 'html' and namespace '' is not an allowed feed format.
which is more confusing because the the namespace is blank and I'm not sure where this god forsaken html element is coming from.
I'm very close to writing my own xml reader and scraping SyndicationFeed, however I want to make sure I exhaust all possible solutions before going that path.
One of the rss feeds if that helps any: http://jobs.huskyenergy.com/RSS