Java Reference
In-Depth Information
This example shows several key features of XML:
• XML documents begin with a preamble , delimited by <? and ?> . The preamble
indicates the version of XML used by the file and the character set encoding for
the file.
• XML documents may contain comments that begin with <!-- and end with --> .
(Comments cannot be nested, however.)
• Elements consist of plain text contained by < and > . (Actually, there are limits to
what can go between these symbols; for this discussion, it's safe to assume that the
name of an element must consist of only alphanumeric characters and the under-
score character.)
• A starting tag indicates the beginning of an element's data; an ending tag is
denoted by the same tag name contained by </ and > .
• White space is not significant between elements.
• Elements may have attributes , which are name-value pairs contained within the
beginning tag.
• Elements are case-sensitive.
• Empty elements contain no elements and are denoted using < and /> .
• Elements may contain other elements or textual data.
Note I've made up the schema for weather data this chapter uses in order to show a sampling of key
features of XML. On the Internet, several schemas for weather data exist, such as the one defined by the
National Weather Service of the U.S. government described at http://www.weather.gov/data/
current_obs/ or the Yahoo! weather format described at http://developer.yahoo.com/weather/ .
XML documents can represent text in one of two ways: as flat character data that
may include five entities that represent the special characters < , > , & , ' , and " , or as a
special unparsed character directive that contains raw character data that the XML
parser accepts without attempting to parse. Table 13-1 shows the five character entity
definitions.
 
Search WWH ::




Custom Search