Javatpoint Logo

91-9990449935

 0120-4256464

XML Validation

A well formed XML document can be validated against DTD or Schema.

A well-formed XML document is an XML document with correct syntax. It is very necessary to know about valid XML document before knowing XML validation.


Valid XML document

It must be well formed (satisfy all the basic syntax condition)

It should be behave according to predefined DTD or XML schema


Rules for well formed XML

  • It must begin with the XML declaration.
  • It must have one unique root element.
  • All start tags of XML documents must match end tags.
  • XML tags are case sensitive.
  • All elements must be closed.
  • All elements must be properly nested.
  • All attributes values must be quoted.
  • XML entities must be used for special characters.

XML DTD

A DTD defines the legal elements of an XML document

In simple words we can say that a DTD defines the document structure with a list of legal elements and attributes.

XML schema is a XML based alternative to DTD.

Actually DTD and XML schema both are used to form a well formed XML document.

We should avoid errors in XML documents because they will stop the XML programs.


XML schema

It is defined as an XML language

Uses namespaces to allow for reuses of existing definitions

It supports a large number of built in data types and definition of derived data types

Next TopicXML DTD