Rules


History
Examples
Benefits
Rules
Links
 

<< Back

An XML document must be well formed. This means the file must follow some basic rules:

  • The document starts with an XML declaration, .

<?xml version="1.0"?>

  • There is a root element in which all others are contained.


<ingredients>
     <item>2/3 C butter</item>
     <item>2 C brown sugar</item>
     <item>1 tsp vanilla</item>
     <item>1 3/4 C unsifted all-purpose flour</item>
     <item>1 1/2 tsp baking powder</item>
    <item>1/2 tsp salt</item>
    <item>3 eggs</item>
    <item>1/2 C chopped nuts</item>
    <item>
</ingredients>

  • All elements must be properly nested. No overlapping is permitted.

Fatal mistake in XML
<ingredients><item></ingredients>chocolate chips</item>

<ingredients><item>chocolate chips</item></ingredients>