Well Formed
A well-formed XML file conforms to XML syntax and adheres to
a strict tree structure, such that there are no
overlapping elements and each element has one parent node.
For example, the following document is not well formed:
<SHAPE> rect <SIZE> </SHAPE> 3x8 </SIZE>
because the elements overlap.
Verifying that a file is well formed
is the first step in assuring that it is ready for use.
The Microsoft IE5 browser will test any XML file for
well-formedness.
The Basic Rules of XML Syntax
The following are the basic rules of XML syntax:
-
XML Declaration
Begin the document with an XML declaration. For
example:
<?xml version="1.0"?>
-
Root Element
Have a root element that completely contains all other
elements.
-
Start And End Tags
Use both start and end tags in non-empty tags.
-
Case Sensitive
XML is case sensitive. For example,
<First_name> is not the same tag as
<first_name>.
-
Empty Tags
End empty tags with "/>".
-
No Overlap
Do not overlap elements.
-
Attributes In Quotes
Enclose attribute values in quotes.
-
< and &
Only use < and & to start tags and entities.
-
Entities
Use only the five pre-existing entity references:
&(&), <(<), >(>),
'('), "(")
An XML file does not need a Document Type Definition (DTD)
or a schema to be tested for well-formedness.