8 Rules for Write Valid or Well Formatted XML Document
XML syntax rules are strongly and very simple logically. XML syntax rules are specifies how to write valid XML document.
XML documents must have only one root element
XML document must have only one root element that is the parent of the all other elements.
Element must have closing tag
In HTML, some element does not have a closing tag.
In XML every element must have closing tag.
Element must be properly nested
In XML, every element properly nested within each other.
Write comment in XML is similar to a HTML,
XML tag case sensitive
XML tag name are case sensitive. <name>, <Name> and <NAME> different tag from each other. Always opening and closing tag must be write with same case.
XML Attribute value must be quoted
XML elements can have specifies several attributes along with name value pair. XML attribute values must be quoted.
White-space is not preserved in XML
XML break multiple white space character to a single white-space.
Output value combine multiple white space into single white space.
In XML special character have some special meaning similar to a HTML.
If you are use < sign or > sign inside XML element, It'll generate a error because document parse interprets assume it's start new element.
For avoiding this error use entity character instead of some special character (<, >).
XML specification defines five predefined entities represent special characters. Following table represent five XML predefined entities lists.