Geeks With Blogs
Shahed's blog Sharing my thoughts and work

Few days back, I was getting HTTP 404 error in my RSS Reader for some feeds. Some of them are very popular feeds and when I checked the feed XML content, I couldn't find any problem. After doing some step by step debugging I found an interesting thing - the path provided for the DTD in <!DCOTYPE... is no longer valid.

When the XmlTextReader was trying to download the DTD from "" it got the exception "HTTP 404 error" and bubbled up to the top level. So, the only option available to me was to tell the XmlTextReader not to try to validate this feed with the provided DTD.

Now, The question comes, how can I tell the XmlTextReader not to validate. While searching for the solution I found a very useful class called "XmlReaderSettings" (in .Net 2.0) where you can do many useful things. but unfortunately the XmlTextReader constructor does not have any overload to pass XmlReaderSettings. You can easily use XmlReaderSettings with XmlReader.

// Create a XmlReaderSettings instance
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreComments = true;
settings.IgnoreProcessingInstructions = true;
//... and any other rules you like to implement

// Then pass the settings object while creating the XmlReader
XmlReader xmlReader = XmlReader.Create(response.GetResponseStream(), settings);

Although XmlTextReader is a subclass of XmlReader but I was looking for a quick fix and didn't have enough time to change much of my code. Then I found this:

xmlReader.XmlResolver = null;

Yes, if you set XmlResover to null, the XmlTextReader will not try to validate the XML with DTD.

Posted on Wednesday, January 10, 2007 10:27 PM | Back to top

Comments on this post: HTTP 404 error if RSS feed contains <!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "">

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Shahedul Huq Khandkar | Powered by: