Well Formed XML
An XML document is called well-formed if it satisfies certain rules, specified by the W3C.
These rules are:
- A well-formed XML document must have a corresponding end tag for all of its start tags.
- Nesting of elements within each other in an XML document must be proper. For example, <tutorial><topic>XML</topic></tutorial> is a correct way of nesting but <tutorial><topic>XML</tutorial></topic> is not.
- In each element two attributes must not have the same value. For example, <tutorial id="001"><topic>XML</topic></tutorial> is right,but <tutorial id="001" id="w3r"><topic>XML</topic></tutorial> is incorrect.
- Markup characters must be properly specified. For example, <tutorial id="001"><topic>XML</topic></tutorial> is right, not <tutorial id="001" id="w3r"><topic>XML</topic></tutorial>.
- An XML document can contain only one root element. So, the root element of an xml document is an element which is present only once in an xml document and it does not appear as a child element within any other element.
Example of a Valid XML document
<?xml version="1.0" ?> <w3resource> <design> html xhtml css svg xml </design> <programming> php mysql </programming> </w3resource>
Example of an invalid XML
<?xml version="1.0" ?> <w3resource> <design> <programming> html xhtml css svg xml </Design> php mysql </programming> </w3resource>
To check whether an XML document is well-formed or not, you have to use an XML parser.
An XML parser is a Software Application, which introspects an XML document and stores the resulting output in memory. If an XML document is parsed by an XML parser and some irregularities are found, it generates some errors and it is then denoted as an XML file , which is not a well-formed XML document.
Well-formed XML is an XML document which follows some rules specified by W3C.
XML Reserved Markup Characters
Next: XML Tutorial
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook