Entity References
An entity in XML is a named body of data, usually text. Entities are often used to represent single characters that cannot easily be entered on the keyboard; they are also used to represent pieces of standard text that occur in many documents, especially if there is a need to allow such text to be changed in one place only.
Special characters can be represented either using entity references, or by means of numeric character references. An example of a numeric character reference is "€", which refers to the Euro symbol by means of its Unicode codepoint in hexadecimal.
An entity reference is a placeholder that represents that entity. It consists of the entity's name preceded by an ampersand ("&") and followed by a semicolon (";"). XML has five predeclared entities:
& & ampersand
< < less than
> > greater than
' ' apostrophe
" " quotation mark
Here is an example using a predeclared XML entity to represent the ampersand in the name "AT&T":
XML | Copy Code |
---|---|
<company_name>AT&T</company_name> |
XML | Copy Code |
---|---|
<company_name>AT&T</company_name> <company_name>AT&T</company_name> |