Well-Formed Documents
Home ] Up ] The Document Prolog ] XML Elements ] The Root Element ] XML Attributes ] Attribute vs. Element? ] Whitespace and Comments ] XML Character Entities ] CDATA Sections ] Processing Instructions ] [ Well-Formed Documents ]

 

 

An XML document is well-formed if it obeys the syntax rules of XML.

For example, in a well-formed XML document:

  • Element and attribute names are legal XML names
  • Markup characters < and & are escaped as entity references when used in text.
  • Every element is closed
  • Every attribute has a value
  • Every attribute value is enclosed within matching quotes (double quote or apostrophe)
  • Every element (except the root element) is a child of exactly one element.
  • Comments are properly formed.

among many other rules.

Well-formedness is the minimum criteria for XML processors to read and interpret XML files.  Unlike with HTML, XML parsers are required to report errors of form.

 
The page was last updated February 19, 2008