XML
Beginner
1 min read
Entity References and Special Characters
Example
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document [
<!-- Custom general entity declaration -->
<!ENTITY company "Acme Corporation">
<!ENTITY copyright "© 2025 Acme Corporation. All rights reserved.">
<!-- Numeric character reference: © = U+00A9 -->
]>
<document>
<!-- Using the five predefined entities -->
<rule>a < b && b > c</rule>
<attr value="He said "hello" and she replied 'hi'"/>
<!-- Using a custom entity -->
<footer>&company; — ©right;</footer>
<!-- Numeric character references (decimal and hex) -->
<symbols>
Euro sign: € <!-- decimal -->
Heart: ♥ <!-- hexadecimal -->
Copyright: © <!-- hex shorthand -->
</symbols>
<!-- Ampersand in attribute value must be escaped -->
<link url="http://example.com?cat=xml&page=1" />
</document>