This tutorial explains the procedure for performing that validation using parsers for the Simple API for XML (SAX) and Document Object Model (DOM), as well as an XML Schema Design (XSD) validator.attribute for an XML Schema without namespaces, in the root/top-level element, or in any other element of the XML Document.Through its support for datatypes and namespaces, XML Schema has the potential to provide the standard structure for XML elements and attributes.
In the first line of example info is the name of element and all three items inside parenthesis are child elements.This means info element must have a child with name In xml document we should use doctype declaration. Parser Configuration Exception; import org.w3*; import sax.there are two Types of DTD these are Internal or external DTD. Now in above example user cannot change anything violating the DTD rules. SAXException; public class Xml Main You may say what is advantage of using XML validation.In such cases we have to check each node before reading for the information. So if we do Validating XML documents, we can reduce lot of burden from our code.Without use of validation, its quite a bit tedious to code and debug.To specify the document structure, we have to supply a DTD or XML schema definition.DTD or schema contains rules about how document should formed or we can say how the elements of document are organized and defined.If we supply DTD in same XML file, we must write DTD rules with in DOCTYPE element.DTD contains Element, attribute and entity references declaration.Actually these are part of XML and has no significant relation with java programming language.I’m going to give simple demo example to illustrate the process of Validating XML.