O'Reilly logo

Web Design in a Nutshell, 2nd Edition by Jennifer Niederst Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

XML Document Syntax

If you are familiar with HTML, a simple XML document shouldn’t be too difficult to understand.

<?xml version "1.0" standalone="no"?>
<!DOCTYPE accounts SYSTEM "simple.dtd">
<accounts>
<customer>
	<name>Bobby Five</name>
	<accountNumber>4456</accountNumber>
	<balance>111.32</balance>
</customer>
</accounts>

In the first line, the code between the <?xml and the ?> is called an XML declaration . This declaration contains special information for the XML processor (the program reading the XML) indicating that this document conforms to Version 1.0 of the XML standard. In addition, the standalone= " no " attribute informs the program that an outside DTD is needed to correctly interpret the document.

The second line is the DOCTYPE declaration. It identifies the root element (accounts in our example) and the DTD for the document. The root element is the element in the document that contains all other elements. It must be unique, which means it may be used only once in the document. All XML documents must have a root element. The root element in HTML and XHTML documents is html, since the whole document is contained within <html> tags.

The last part of the declaration is a pointer to the DTD itself. The SYSTEM identifier points to the DTD resource by location (its URL). In our example, the DTD of the document resides in a separate local file named simple.dtd. As an alternative, some declarations use the PUBLIC identifier to point to the DTD (or other resource) by a unique ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required