XML DocumentIn its simplest form, an XML document is one (and only one) element. This top-level element is called the root. However, because an element can contain other elements, the document can be large and complex. The only rule to remember is that the document cannot have more than one root. The following is a valid XML document: <set> <book isbn='0-672-32054-1'/> <book isbn='0-7897-2215-1'/> </set> XML DeclarationThe document can start with an optional XML declaration. The declaration has a number of attributes to specify:
The following document has a declaration with optional encoding and standalone attributes: <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <set> <book isbn='0-672-32054-1'/> <book isbn='0-7897-2242-9'/> </set> Document Type DeclarationAn optional model can be associated to the document, such as a Document Type Definition (DTD), or another model, such as the forthcoming XML Schema. The document references the model in the document type declaration (not to be confused with the DTD): <?xml version="1.0"?> <!DOCTYPE set SYSTEM "http://www.psol.com/axs/bookset.dtd"> <set> <book isbn='0-672-32054-1'/> <book isbn='0-7897-2242-9'/> </set> The document type declaration can be any of the following:
|