XML Tutorial/Introduction/Entity

Материал из Web эксперт
Перейти к: навигация, поиск

Illegal PCDATA Characters and Escaping Characters

   <source lang="xml">

<comparison>6 is < 7 & 7 > 6</comparison> You can"t put < or & characters into PCDATA. There are two ways you can get around this: escaping characters, or enclosing text in a CDATA section. To escape the < or &, you replace any < with < and any & with &. The previous XML example could be made well formed: <comparison>6 is < 7 & 7 > 6 </comparison> < and & are known as entity references. The following entities are defined in XML: & - the & character < - the < character > - the > character ' - the ` character " - the " character Other characters can also be escaped by using character references. These are strings such as &#nnn;, where nnn would be replaced by the Unicode number of the character. Or &#xnnn; with an x preceding the number, where nnn is a hexadecimal representation of the Unicode character. To include the copyright symbol ((c)), inserting © or ©. Entity references must be declared</source>


SELECTED CHARACTER CODES

   <source lang="xml">

Name Entity Reference Trademark &#153: Copyright © Register ® Plus or minus ± One-quarter ¼ One-half ½ Three-quarters ¾</source>