I am opening XML file that refers to a DTD as follows:
<?xml version="1.0" encoding="windows-1250"?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
Here is the part of C# code:
public static XmlDocument FromUri(string uri)
{
XmlDocument xmlDoc;
WebClient webClient = new WebClient();
using (Stream rssStream = webClient.OpenRead(uri))
{
XmlTextReader reader = new XmlTextReader(rssStream);
xmlDoc = new XmlDocument();
xmlDoc.XmlResolver = null;
xmlDoc.Load(reader);
}
return xmlDoc;
}
When I try to Load 'reader' I get the following error: Expected DTD markup was not found. Is there any way to get the parser to ignore the Doctype element? Or maybe, I can do something more efficient?