Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

1.11 Character references


Many character encodings cannot natively represent the full range of ISO-10646 characters. When an XML document contains characters that cannot be represented natively in the chosen encoding, then these nonrepresentable characters must be written as character references. Character references begin with the character sequence &# followed by the ISO-10646 value of the character to be written in either decimal or hexadecimal form. If the character value is represented in hexadecimal form, then it must be preceded by an x. Character references end with ;.

Character references can only be used for attribute and element content. Nonrepresentable characters appearing as part of element or attribute names or as part of processing instructions or comments cannot be written using character references; rather, a more suitable encoding must be used instead.


Character references

<?xml version='1.0' encoding='US-ASCII' ?>
<Personne occupation='&#xe9;tudiant' >

Character references appearing in element and attribute content

  • + Share This
  • 🔖 Save To Your Account