BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

XML Validator

Last Updated: October 31, 2018 by Chaitanya Singh | Filed Under: XML Tutorial

The cool thing about XML is that it can be validated for syntax error using DTD or Schema. In this guide we will learn what is a valid xml, what are the rules and the ways to check for a valid XML document.

Well Formed XML document

An XML document with correct syntax is known as valid XML document. Lets see few important rules to check for syntax errors.

Rules:
1. All XML documents must have a root element.
2. XML is a case sensitive language so you should be careful with the case while opening and closing tags.
3. All XML tags must have a closing tag.
4. XML attribute name should not be quoted while its value must be quoted.

For more rules check this guide: XML Syntax

Ways to check a valid XML document

There are two document type definitions that can used with XML document to check whether the XML document is valid.
1. XML DTD (Document Type Definition)
2. XML Schema – An XML-based alternative to the Document Type Definition

1. XML DTD

DTD defines the structure of XML document that can be validated against the XML document to check for the syntax errors. XML DTD defines the structure by mentioning the XML elements in such a way so that the complete structure of XML document can be understood. The DTD file has .dtd extension.

2. XML Schema

The Schema does the same thing that a DTD can do. It also defines the structure of the XML document but unlike DTD it is an XML file, in addition to that Schema supports data types and namespaces.

Top Related Articles:

  1. XML Comments
  2. XML DTD
  3. XML Attributes
  4. XML Example
  5. JSON vs XML

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap