Java Reference
In-Depth Information
CHARACTER PREDEFINED ENTITY
>
>
Here's an element that makes use of a predefined entity:
<text> This is parsed character data within a &lt;text&gt; element.</text>
The content of this element is the following string:
This is parsed character data within a <text> element.
Here's an example of an XML document containing several elements:
<?xml version="1.0"?>
<address>
<buildingnumber>29</buildingnumber>
<street>South LaSalle Street</street>
<city>Chicago</city>
<state>Illinois</state>
<zip>60603</zip>
</address>
This document evidently defines an address. Each tag pair identifies and categorizes the information
between the tags. The data between <address> and </address> is an address, which is a composite of five
further elements that each contain character data that forms part of the address. You can easily identify what
each of the components of the address is from the tags that enclose each subunit of the data.
Rules for Tags
The tags that delimit an element have a precise form. Each element start tag must begin with < and end with
> , and each element end tag must start with </ and end with > . The tag name — also known as the element
type name — identifies the element and differentiates it from other elements. Note that the element name
must immediately follow the opening < in the case of a start tag and the </ in the case of an end tag. If you
insert a space here it is incorrect and is flagged as an error by an XML processor.
Because the <address> element contains all of the other elements that appear in the document, this is
the root element. When one element encloses another, it must always do so completely if the document is to
be well-formed. Unlike HTML, where a somewhat cavalier use of the language is usually tolerated, XML
elements must never overlap. For example, you can't have
<address><zip>60603</address></zip>
An element that is enclosed by another element is referred to as the child of the enclosing element, and
the enclosing element is referred to as the parent of the child element. In the earlier example of a document
that defined an address, the <address> element is the parent of the other four because it directly encloses
each of them, and the enclosed elements are child elements of the <address> element. In a well-formed
document, each start tag must always be matched by a corresponding end tag, and vice versa. If this isn't the
case, the document is not well-formed.
Search WWH ::




Custom Search