Core XML syntax rules:
<!-- 1. All tags must be closed -->
<item>value</item> <!-- correct -->
<br/> <!-- self-closing, also correct -->
<!-- 2. Tags are case-sensitive -->
<Name>Alice</Name> <!-- <name> and <Name> are different elements -->
<!-- 3. Tags must be properly nested (no overlapping) -->
<b><i>text</i></b> <!-- correct -->
<!-- 4. Attribute values must be quoted -->
<book id="1" lang='en'>...</book>
<!-- 5. Special characters must be escaped -->
<description>Price < $10 & in stock</description>
The five predefined XML entities:
< → <
> → >
& → &
' → '
" → "
Use a CDATA section to include large blocks of text containing special characters without escaping each one:
<script>
<![CDATA[
if (a < b && b > c) {
alert("condition met");
}
]]>
</script>