Java Reference
In-Depth Information
The Extensible Markup Language, or XML, is a metalanguage for creating markup languages
used to describe structured data. XML is a self-describing language, composed of tags and val-
ues. It is often used to describe objects that are passed in messages between applications. An
example of a simple XML document is included in Listing 10.1.
L ISTING 10.1
item.xml
<?xml version=”1.0”?>
<ITEM>
<ID>33445</ID>
<DESCRIPTION> Austin Powers: International Man of Mystery</DESCRIPTION>
<PRICE>19.95</PRICE>
<QUANTITY>56</QUANTITY>
</ITEM>
The first line of this snippet describes a processing instruction that states that this XML docu-
ment is based on version 1 of the XML specification. Processing instructions begin with a less-
than sign and a question mark ( <? ) and end with a question mark and a greater than sign ( ?> ).
The rest of this document describes an ITEM object with four attributes: ID , DESCRIPTION ,
PRICE , and QUANTITY . Each of these attributes is contained in an open < TAG > and closed </ TAG >
pair. You should notice how the hierarchy of the object is described in a container-like fashion,
wherein the attributes of the ITEM are between the ITEM 's open and closing tags. This shows the
parent/child relationship of the ITEM object. All XML documents can be viewed as navigable
tree structures. Figure 10.1 shows the standard structure of an XML document.
Document Root
ITEM
ID
DESCRIPTION
PRICE
QUANTITY
F IGURE 10.1
The XML document tree structure.
Search WWH ::




Custom Search