How to put ASCII decimal/hex values in an XML file

For example, to put a pound (or hash) sign # in an XML file, you can use either of the following:

ASCII decimal and Hex values in XML


23 in hex = 2×16+3 = 35 in decimal

So the syntax is the ampersand and the hash tag followed by the number, then followed by a semicolon.
If doing hex, add the letter “x” before the number.

One more example, a Carriage Return/Line Feed:


You can find an example ASCII character chart here.

How to encode other characters, such as ampersand, a double or single quote

Other common shortcuts (called entity references) are:

&amp;  ampersand sign 
&lt;  less than sign 
&gt;  greater than sign 
&quot; for a double quote 
&apos; for a single quote (apostrophe) 

CDATA turns off parsing

For long strings where you want to turn off the parser temporarily (in order to allow special characters): '
Other common shortcuts are:

<![CDATA[  anything goes here, such as &, <, > and so on ]]>

Copy and paste from here: 
<![CDATA[  ]]>
and replace the inner brackets with your CDATA text. 

Trademark and Copyright Symbols

Other common symbols are:

Registered Trademark: &#174; and Copyright: &#169;


Leave a Reply