Please visit our sponsors !
DTD - XML building blocks
The main building blocks of both XML and HTML documents are
tags like <body>....</body>.
The building blocks of XML documents
Seen from a DTD point of view, all XML
documents (and HTML documents) are made up by the following simple building blocks:
- Elements
- Tags
- Attributes
- Entities
- PCDATA
- CDATA
The following is a brief explanation of each of the building blocks:
Elements
Elements are the main building blocks of both XML and HTML documents.
Examples of
HTML elements are "body" and "table". Examples of XML elements could be
"note"
and "message". Elements can contain text, other elements, or be
empty. Examples of empty HTML elements are "hr", "br" and
"img".
Tags
Tags are used to markup elements.
A starting tag like <element_name> marks up the beginning of an
element, and an ending tag like </element_name> marks up the end of
an element.
Examples:
body element marked up with body tags:
<body>body text in between</body>.
message element marked up with message tags:
<message>some message in between</message> |
Attributes
Attributes provide extra information about elements.
Attributes are always placed inside the starting tag of an element. Attributes
always come in
name/value pairs. The following "img" element has additional information about a source file:
<img src="computer.gif" /> |
The name of the element is "img". The name of the attribute is
"src". The value of the attribute is "computer.gif".
Since the element itself is empty it is closed by a " /".
Entities
Entities are variables used to define common text. Entity references are references to entities.
Most of you will know the HTML entity reference: " ". This "no-breaking-space" entity is used in HTML to insert an extra space in
a document.
Entities are expanded when a document is parsed by an XML parser.
The following entities are predefined in XML:
Entity References |
Character |
< |
< |
> |
> |
& |
& |
" |
" |
' |
' |
PCDATA
PCDATA means parsed character data.
Think of character data as the text found between the start tag and the end
tag of an XML element.
PCDATA is text that will be parsed by a parser. Tags inside the text will be treated as markup and entities will be expanded.
CDATA
CDATA also means character data.
CDATA is text that will NOT be parsed by a parser.
Tags inside the text will NOT be treated as markup and entities will not be expanded.
Jump to: Top of Page
or HOME or
Printer friendly page
Search W3Schools:
What Others Say About Us
Does the world know about us? Check out these places:
Dogpile
Alta Vista
MSN
Google
Excite
Lycos
Yahoo
Ask Jeeves
We Help You For Free. You Can Help Us!
W3Schools is for training only. We do not warrant its correctness or its fitness for use.
The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our
terms of use and
privacy policy.
Copyright 1999-2002 by Refsnes Data. All Rights Reserved
|