DTD Entities
Estimated study time: 10 minutes.
An entity in a DTD is a shortcut — a name that stands in for a piece of text or content, so you don't have to repeat it throughout a document.
Built-in Entities
XML reserves a few characters for its own syntax, so they must be written as entities instead of literally:
<for<>for>&for&"for"'for'
General Entities
Custom entities you define yourself, useful for repeated text like a company name or a long boilerplate string.
<!DOCTYPE course [
<!ENTITY provider "Uncodemy">
]>
<course>
<title>Data Analytics by &provider;</title>
</course>
Every occurrence of &provider; is replaced with Uncodemy when the document is parsed.
External General Entities
<!ENTITY logo SYSTEM "logo.txt">
Pulls content in from an external file rather than defining it inline.
Parameter Entities
Used only within the DTD itself (not the document body) to reuse pieces of the DTD definition, declared with a % sign.
<!ENTITY % text "(#PCDATA)">
<!ELEMENT title %text;>