DTD - XML building blocks
The main building blocks of XML and HTML documents are element tags.
XML Document Building Blocks
All XML documents (and HTML documents) are made up of the following simple building blocks:
- element
- Property
- Entity
- PCDATA
- CDATA
element
Elements are the main building blocks of XML and HTML documents.Main building blocks。
Examples of HTML elements are "body" and "table". Examples of XML elements are "note" and "message". Elements can contain text, other elements, or be empty. Examples of empty HTML elements are "hr", "br", and "img".
Example:
<message>some text</message>
Attribute can provideAdditional Information About Elements。
Attributes are always placed in the start tag of an element. Attributes always take the form ofname/valuepairs. The following "img" element has additional information about the source file:
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 with a " /".
Entity
Entities are variables used to define ordinary text. Entity references are references to entities.
Most of you are familiar with the HTML entity reference: " ". This "non-breaking space" entity is used in HTML to insert an extra space in a document.
When a document is parsed by an XML parser, entities are expanded.
| entity reference | 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 the parser. The parser will examine this text for entities and markup.
Tags in the text will be treated as markup, and entities will be expanded.
However, parsed character data should not contain any &, <, or > characters; you need to replace them with the &, <, and > entities, respectively.
CDATA
CDATA means character data.
CDATA is text that will not be parsed by the parser.Tags in this text will not be treated as markup, and entities in it will not be expanded.
other extensions