Escape characters for HTML and XML languages

Source: Internet
Author: User
Tags character set end
Xml HTML the escape character in

HTML, >,& and so on have special meaning, (the first two characters used for link check,& for escape), cannot be used directly. When you use these three characters, you should use their escape sequences, as follows:

& or &

&

And

< or <

<

Less than sign

> or >

>

Greater-than sign

"

"

Double quotes

Space

©

©

Copyright symbol

®

®

Register character

The former is a character escape sequence, and the latter is a numeric escape sequence. The number is converted to the ASCII value of the character. For example & lt; Font > shown as, if directly written as is considered a link to sign.

What needs to be stated is:

A. there should be no spaces between the characters of the escape sequence;

B. the escape sequence must end with ";" ;

c. a separate & is not considered to be an escape start;

d. Case sensitive.

Another character that needs to be escaped is the quotation mark, whose escape sequence is "" "or" "

The character set used by HTML is the ISO &859 Larin-1 character set, which has many characters that cannot be entered on a standard keyboard. Only escape sequences can be used for these special characters.

XML Escape Character

An illegal XML character must be replaced with the corresponding entity.

If you use a character similar to "<" in an XML document, the parser will get an error because the parser will think that this is the beginning of a new element. So you should not write the code as follows:

If salary < 1000 Then

To avoid this, you must convert the character "<" to an entity, as follows:

If salary < 1000 Then

Here are five entities that are predefined in an XML document:

<

<

Less than sign

>

>

Greater-than sign

&

&

And

'

'

Single quotation mark

"

"

Double quotes

The entity must begin with the symbol "&" with the symbol ";" End.

Note: Only the "<" and "&" characters are strictly prohibited for XML. The rest is legal, and in order to reduce errors, using entities is a good habit.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.