XML Syntax

Like HTML, XML is based on the Standard Generalized Markup Language, or SGML. This common heritage renders XML familiar in look and feel to those accustomed to HTML. XML syntax uses matching start and end tags, such as <string> and </string> , to demarcate logical sections of a document or data set. A unit of information enclosed by tags is called an element . This simple syntax is easy to process by a computer, with the added benefit of remaining understandable to humans.

The best way to illustrate the basic features of XML is with a simple example. The document shown in Listing 1-1 contains the XML representation of a customer object that might have been exported from a customer database.

Listing 1-1 A simple XML document
<?xml version="1.0" encoding="UTF-8"?> <customer> <name>Jane Doe</name> <address region="USA"> <street>6236 Nicolet Rd</street> <city>Richmond</city> <state>VA</state> <postal>23225</postal> </address> <birthday> <month>10</month> <day>11</day> <year>1949</year> </birthday> </customer>

This example document contains the basic XML structural features. First there is the required prolog--also called the XML declaration--containing XML version and character encoding information. The remainder of the document is simply the listing of elements that constitute the customer information.


© 2000 Apple Computer, Inc. (Last Updated 14 July 2000)