YouTip LogoYouTip

Dtd Validation

# DTD Validation * * * You can validate your XML against a DTD using Internet Explorer. * * * ## Validation via XML Parser When you attempt to open an XML document, the XML parser may generate errors. By accessing the `parseError` object, you can retrieve the exact error code, text, and even the line number where the error occurred. **Note:** The `load()` method is used for files, while the `loadXML()` method is used for strings. ## Example var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.validateOnParse="true"; xmlDoc.load("note_dtd_error.xml"); document.write("
Error Code: "); document.write(xmlDoc.parseError.errorCode); document.write("
Error Reason: "); document.write(xmlDoc.parseError.reason); document.write("
Error Line: "); document.write(xmlDoc.parseError.line); [Try it yourself Β»](#) (#) * * * ## Disabling Validation You can disable validation by setting the XML parser’s `validateOnParse` property to `"false"`. ## Example var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.validateOnParse="false"; xmlDoc.load("note_dtd_error.xml"); document.write("
Error Code: "); document.write(xmlDoc.parseError.errorCode); document.write("
Error Reason: "); document.write(xmlDoc.parseError.reason); document.write("
Error Line: "); document.write(xmlDoc.parseError.line); [Try it yourself Β»](#) * * * ## Generic XML Validator To help you validate XML files, we’ve created this (#), enabling you to validate any XML file. * * * ## The parseError Object You can read more about the `parseError` object in our (#).
← Dtd ExamplesDtd Entities β†’