In this case, you also have the option of
writing this element using the special empty
This is the one case where a start-tag
doesn't need a separate end-tag, because they are both combined together into
this one tag. In all other cases, they do.
Recall from our discussion of element names
that the only place we can have a space within the tag is before the closing
">". This rule is slightly different when it comes to empty
elements. The "/" and ">" characters always have to be
together, so you can create an empty element like this:
but not like these:
Empty elements really don't buy yoult;/parody> syntax to just <parody/>.
Interestingly, nobody in the XML community seems
to mind the empty element syntax, even though it doesn't add anything to the
language. This is especially interesting considering the passionate debates
that have taken place on whether attributes are really necessary.
One place where empty elements are very
often used is for elements that have no (or optional) PCDATA, but instead have
all of their information stored in attributes. So if we rewrote our <name> example
without child elements, instead of a start-tag and end-tag we would probably
use an empty element, like this:
first="John" middle="Fitzgerald Johansen"
Another common example is the case where
just the element name is enough; for example, the HTML <BR> tag might
be converted to an XML empty element, such as the XHTML <br/> tag.
(XHTML is the latest "XML-compliant" version of HTML.)
It is often very code is a one-to-one mapping between a
set of characters and the corresponding numbers to represent those characters.
A character encoding
is the method used to represent the numbers in a character code digitally, (in
other words how many bytes should be used for each number, etc.)
character code/encoding that you might have come