XML Document Syntax
XML Document Syntax:
Another important aspect of a well-formed XML document is the document syntax. XML represents data and not content or layout like other markup languages such as HTML. Data has very strict structure and format rules. XML also has very strict rules about the syntax used to represent that data. Developers who are used to coding with the somewhat forgiving syntax of HTML will have some adjustments to make when dealing with XML syntax.
For starters, XML element names must start and end with the same case. This is not well-formed XML:
This is level 2 of the nested elements
The tag name started with must be closed with , not
, to be considered well-formed XML.
Quotes must be used on all attribute names. Something like this will not be considered well-formed XML:
Attributes must be formatted with single or double quotes to be considered wellformed XML:
Comments should always follow the SGML comment tag format:
Element tags must always be closed. HTML and other forms of markup are somewhat forgiving, and can often be left open or improperly nested without affecting the content or display of a page. XML parsers and other tools that read and manipulate XML documents are far less forgiving about structure and syntax than browsers.