Xmlvalidatingreader dtd

As far as using the XSLT code to insert the DOCTYPE, I couldn't use it because the XML files that I receive could be very large and I do not want to regenerate the whole file just to check for its validity.

As for creating a custom Xml Reader, I initially tried it but it is not that simple since in order to fake the DOCTYPE attribute one has to first determine that it is missing or invalid and then simulate it only in that case. Here is what I ended up doing: Because the Validating Reader does not throw any exceptions if DOCTYPE is missing I just check Xml Document.

Passed the name of an XML file as a command-line argument, the program validates the file against the DTD or schema information contained or referenced in the file.

If the validation is successful, a message to that effect is displayed.

If there is a validation error, or an exception is thrown, the relevant information is displayed to the user.

var microsoft = microsoft

Note that you do not have to specify a handler for validation errors.

Google pointed me to this, but it seems Xml Validating Reader is obsolete (at least, that's what Mono Develop tells me).

Edit: I'm trying Mehrdad's tip, but I'm having trouble. Validation Event Handler = new Validation Event Handler(/*trouble is here*/); Xml Reader validating Reader = Xml Reader.

The Xml Validating Reader class, as its name implies, provides data validation capabilities.

Specifically, it can validate XML data against a document type definition (DTD), an XML schema definition language (XSD) schema, or an XML Data Reduced (XDR) schema.

When the following code is executed the XML gets resolved through the XMLResolver and gets correctly validated against the locally stored DTD file.

You must have an account to comment. Please register or login here!