Search code examples
c#xmlrssargotic

XMLException when processing RSS


I've been trying to process RSS feeds using Argotic for my newsreader application. For most of them it works fine, but on some feed (like this) it breaks with the following:

Additional information: 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 error was straightforward, I passed an XMLReaderSettings object with DtdProcessing enabled. But then the following appeared:

An unhandled exception of type 'System.Xml.XmlException' occurred in System.Xml.dll Additional information: The ';' character, hexadecimal value 0x3B, cannot be included in a name. Line 9, position 366.

The code I am using:

    XmlReaderSettings settings = new XmlReaderSettings();
    settings.IgnoreComments = true;
    settings.IgnoreWhitespace = true;
    settings.DtdProcessing = DtdProcessing.Parse;

    XmlReader reader = XmlReader.Create(this.url, settings);
    RssFeed feed = new RssFeed();
    feed.Load(reader);

What am I missing?


Solution

  • It seems ignoring the DtdProcessing solved my problem.

    settings.DtdProcessing = DtdProcessing.Ignore;