1. Every XML document must have a root element
<bookstore>
<book>...</book>
</bookstore>
2. Tags must be properly closed
<author>John</author>
<line-break /> <!-- Self-closing tag -->
3. Tags are case-sensitive
<Title>Correct</Title>
<title>Incorrect if you opened with Title</title>
4. Elements must be properly nested
<!-- Correct -->
<note><to>John</to><from>Jane</from></note>
<!-- Incorrect -->
<note><to>John<from>Jane</to></from></note>
5. Attribute values must be quoted
<book genre="fiction" year="2023">
...
</book>
6. Use of a prolog (optional but recommended)
<?xml version="1.0" encoding="UTF-8"?>
7. Special characters must be escaped
-
Use entity references for characters like <, >, &, ', ":
-
< → <
-
> → >
-
& → &
-
' → '
-
" → "
8. Whitespace is preserved
9. Comments follow a strict format
<!-- This is a valid XML comment -->
10. Custom tags are allowed