- Escaping XML Data
- XML Encoding
- XML 1. 0 EBNF
- XML 1.1 EBNF
- Byte Order Marker
- XML Schemas
- XML Mixed Content
- Describing Complex Structures in XML
An XML document consists of the following parts
An optional xml declaration, this typically looks like this.
|Example XML Declaration||Copy Code|
<?xml version="1.0" encoding="utf-8" ?>
If an XML Declaration is provided, it MUST be the first thing in the XML file, and first means first, no comments, no whitespace, nothing is allowed before it. The only exception to this is a Byte Order Marker (BOM).
These are optional, and typically provide information to external tools, i.e. the XSL transform that should be applied or the schema to be used for validation.
|Example Processing Instruction||Copy Code|
<?xml-stylesheet type="text/xsl" href="/Content/Glossary/main.xsl"?>
Document Type Declaration (DTD)
The Document Type Declaration is optional, and describes the data contained in the root element
Comments are optional.
Root XML Element
The XML Document MUST contain a single XML Element, which contains the documents data.
The syntax for an XML Document is described by the W3C using EBNF as follows.
 document ::= prolog element Misc* - Char* RestrictedChar Char*  prolog ::= XMLDecl Misc* (doctypedecl Misc*)?  XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S?'?>'
 VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')  Eq ::= S? '=' S?  VersionNum ::= '1.1'  Misc ::= Comment | PI | S  doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' intSubset ']' S?)? '>'
The EBNF above is taken from the XML 1.1 Spec. If you were to look at the XML 1.0 spec you would notice a small but significant difference.
 prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?