XML DTD Building Blocks
All XML documents are composed of elements, attributes, entities, PCDATA, and CDATA. These are the fundamental building blocks that make up XML documents.
Elements are the main building blocks of both XML and HTML documents.
<title>A Great Book</title>
publisher are elements.
Learn more about Elements in the DTD Elements Section
Attributes provide extra information about elements.
Attributes are name-value pairs always placed inside the opening tag of an element.
<img src="myimage.png" />
- the name of the element is
- the name of the attribute is
- the value of the attribute is
Learn more about Attributes in the DTD Attributes Section
Some characters have a special meaning in XML, like the less than sign (<) that defines the start of an XML tag.
An entity is composed of three parts:
- An ampersand (&)
- An entity name
- A semicolon (;)
<!ENTITY entity-name "entity-value">
The following entities are predefined in XML:
Entities are expanded when a document is parsed by an XML parser.
PCDATA means parsed character data.
PCDATA is text that will be parsed by the XML parser.
Tags inside the PCDATA will be treated as markup and entities will be expanded.
The parsed character data should not contain any
> characters; these should be represented by the entities
XML parser examines the data and ensures that it doesn't contain entity. If an entity is found, it will be expanded.
<!DOCTYPE book [
<!ELEMENT book (title,author,publisher)>
<!ELEMENT author (#PCDATA)>
CDATA means character data.
Tags inside the CDATA text are not treated as markup and entities will not be expanded.