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:

  • &lt; for <
  • &gt; for >
  • &amp; for &
  • &quot; for "
  • &apos; 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;>
💡 Tip: Use general entities to avoid repeating long, unchanging strings across a document — if the value ever changes, you only update it in one place.

Ready to go beyond the basics?

Get hands-on training, live mentorship, and placement support with the Data Analytics Course at Uncodemy.

Explore XML Course →