Validating XML Documents with DTDs in Internet Explorer

By default, Internet Explorer actually does validate XML documents with DTDs as it loads them, but you won't see any validation errors unless you check the parseError object.

Turning Validation On and Off

You can turn document validation on or off with the document object's validateOnParse property, which is set to true by default.

Here's an example. In this case, I'll load this XML document, ch07_10.xml. This document has a validation problem because the <NAME> element is declared to contain only a <FIRST_NAME> element, not a <LAST_NAME> element:

Listing . ch07_10.xml
 <?xml version = "1.0" standalone="yes"?> <!DOCTYPE DOCUMENT [ <!ELEMENT DOCUMENT (CUSTOMER)*> <!ELEMENT CUSTOMER (NAME,DATE,ORDERS)> ...

Get Real World XML now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.