E
engwar
The title says it all. How do I use XMLDocument.Validate() against a
DTD.
In all my Googling about this I only find examples of how to validate
an XMLReader or XmlValidatingReader against a DTD.
The reason I want to avoid the readers is that I want an XmlDocument
that is not forward-only so I can loop through the doc again after
validating it.
I want to do something like the following but I keep getting the error
"the XmlSchemaSet on the document is either null or has no schemas in
it. Provide schema information before calling Validate."
What am I doing wrong?
string myXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><!DOCTYPE
book SYSTEM \"book.dtd"><book><title>I Robot</title><author>Asimov</
author></book>";
XmlDocument r = new XmlDocument();
r.LoadXml(myXml);
ValidationEventHandler eventHandler = new
ValidationEventHandler(ValidationEventHandler);
r.Validate(eventHandler);
DTD.
In all my Googling about this I only find examples of how to validate
an XMLReader or XmlValidatingReader against a DTD.
The reason I want to avoid the readers is that I want an XmlDocument
that is not forward-only so I can loop through the doc again after
validating it.
I want to do something like the following but I keep getting the error
"the XmlSchemaSet on the document is either null or has no schemas in
it. Provide schema information before calling Validate."
What am I doing wrong?
string myXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><!DOCTYPE
book SYSTEM \"book.dtd"><book><title>I Robot</title><author>Asimov</
author></book>";
XmlDocument r = new XmlDocument();
r.LoadXml(myXml);
ValidationEventHandler eventHandler = new
ValidationEventHandler(ValidationEventHandler);
r.Validate(eventHandler);