Original Post
I'm writing a fairly large module to our product here at work (READ: I really can't show you very much code). I'm having a problem loading documents that define a DTD, e.g. GDNet RSS. Documents without DTD definitions load fine, e.g. CNN World News RSS. My problem is specifically limited to this bit of code (the minimum amount of code to replicate the problem) I'm using .Net framework v1.1 and if you really want to know, I'm using C#, Visual Studio.Net 2003, and I got the RSS 2.0 spec from Harvard Law. Quite frankly, it's the worst excuse for a spec I have ever read, but atleast the spec itself is pretty simple. Funny, the IRC spec was horrifying, but atleast the spec document was official and technical.
XmlTextReader reader = new XmlTextReader("http://www.gamedev.net/xml/");
XmlDocument doc = new XmlDocument();
doc.Load(reader);
I've tried using validating readers (I believe this is the code in the msdn examples on using XmlDocuments)
XmlTextReader reader = new XmlTextReader("http://www.gamedev.net/xml/");
XmlValidatingReader validator = new XmlValidatingReader(reader);
validator.ValidationType = ValidationType.DTD;
XmlDocument doc = new XmlDocument();
doc.Load(validator);
but to no avail. Each block dies on the call to doc.Load().
Unhandled Exception: System.Xml.XmlException: The expected DTD markup was not fo
und. Line 1, position 3.
at System.Xml.XmlScanner.ScanDtdContent()
at System.Xml.Schema.DtdParser.ScanDtdContent()
at System.Xml.Schema.DtdParser.ParseDtdContent()
at System.Xml.Schema.DtdParser.ParseDocTypeDecl()
at System.Xml.Schema.DtdParser.Parse()
at System.Xml.XmlTextReader.ParseDtd(XmlScanner scanner)
at System.Xml.XmlTextReader.ParseTag()
at System.Xml.XmlTextReader.ParseRoot()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlValidatingReader.ReadWithCollectTextToken()
at System.Xml.XmlValidatingReader.Read()
at System.Xml.XmlLoader.LoadCurrentNode()
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean prese
rveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at RssReader.Class1.Main(String[] args) in c:\documents and settings\smcbethmy documents\visual studio projects\rssreader\class1.cs:line 20