DTD - XML building blocks
The main building blocks of XML and HTML documents are element tags.
XML document building blocks
All XML documents (as well as HTML documents) are made up of the following simple building blocks:
- Element
- property
- Entities
- PCDATA
- CDATA
Element
Elements are themain building blocks.
of XML and HTML documents.
Example:
some textAttributes can provideextra information about elements.
Attributes are always placed in the start tag of an element. Attributes always appear inname/valuepairs. The "img" element below has extra information about the source file:
The element's name is "img". The attribute's name is "src". The attribute's value is "computer.gif". Since the element itself is empty, it is closed with a " /".
Entities
Entities are variables used to define ordinary text. An entity reference is a reference to an entity.
Most students are familiar with this HTML entity reference: " ". This "non-breaking space" entity is used in HTML to insert an extra space into a document.
When a document is parsed by an XML parser, entities are expanded.
| Entity references | Character |
|---|---|
| < | < |
| > | > |
| & | & |
| " | " |
| ' | ' |
PCDATA
PCDATA means parsed character data.
You can think of character data as the text between the start tag and the end tag of an XML element.
PCDATA is text that will be parsed by a parser. The text is checked by the parser for entities and markup.
Tags in the text are treated as markup, and entities are expanded.
However, parsed character data should not contain any &,< or > characters; you need to use &,< and > entities to replace them respectively.
CDATA
CDATA means character data.
**CDATA is text that is not parsed by a parser.** Tags in this text are not treated as markup, and entities are not expanded.