Special XML characters (and how to avoid &)
Some characters cannot directly expressed in XML. They need to be expressed in a special way using XML's escape charter &
. They are:
Character | XML Representation |
---|---|
< | < |
& | & |
> | > |
There are two more characters that may need "escaping". Details can be found on Wikipedia.
One example for is mechanism is the DisplayArtistName for the collaboration George Benson & Al Jarreau. This needs expressing in XML as
<DisplayArtistName>George Benson & Al Jarreau</DisplayArtistName>
Someone receiving such information must "un-escape" the &
to & – otherwise, if he ingests the name as is into his database and if he then creates a new XML message, he may end up sending:
<DisplayArtistName>George Benson &amp; Al Jarreau</DisplayArtistName>
which is then displayed as "George Benson & Al Jarreau"...