In this tutorial you will learn about the XML Validity and its application with practical example.
An XML Document is said to valid if it is well formed and adhere the rules defined in Document Type Definition (DTD).
Table Of Contents−
A well formed XML Document must be syntactically correct:
- XML documents must have a root element
- XML elements must have a closing tag
- XML tags are case sensitive
- XML elements must be properly nested
- XML attribute values must be quoted
- XML elements should be closed in proper order
Lets take a look at Well formed XML Document
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<inbox> <message id="1"> <from>John</from> <subject>Test Message 1</subject> <body>Hello John!</body> </message> <message id="2"> <from>Chris</from> <subject>Test Message 2</subject> <body>Hello John!</body> </message> <message id="3"> <from>Adam</from> <subject>Test Message 3</subject> <body>Hello John!</body> </message> </inbox> |
XML DTD
XML DTD is used to define the structure for an XML document. It defines the structure with a set of legal elements that can be used to create XML Document.