Escape characters in HTML and XML

Source: Internet
Author: User

Escape characters in HTML

<,>, &, And so on have special meanings in HTML. (the first two characters are used for the link sign and escape .). When these three characters are used, their escape sequences should be used, as shown below:

& Amp; or & #38; & and
& Lt; or & #60; <minor sign
& Gt; or & #62;> greater
& Quot; "Double quotation marks
& Nbsp; space
& Copy; Copyright Operator
& Reg

The former is the character escape sequence, and the latter is the numerical escape sequence. Convert the number to the ASCII value corresponding to the character. For example, & lt; font & gt; is displayed as, <font>. If it is written directly, it is considered as a link signature.
A. There cannot be spaces between characters in the escape sequence;
B. The escape sequence must end;
C. Separate & not considered as the start of escape;
D. case sensitive.
Another character that needs to be escaped is a quotation mark. Its Turn-to-order column is "or """
The character set used by HTML is the iso & 859 Larin-1 character set, which contains many characters that cannot be entered on the standard keyboard. Only escape sequences can be used for these special characters.

XML escape characters

Invalid xml characters must be replaced with corresponding entities.

If you use a character similar to "<" in the XML document, the parser will encounter an error because the parser considers this as the beginning of a new element. So it should not be written as belowCode:
<Message> If salary <1000 then </message>
To avoid this situation, you must convert the character "<" to an object, as shown below:
<Message> If salary <1000 then </message>
The following are five pre-defined entities in the XML document:
& Lt; <Yu no.
& Gt;> greater
& Amp; & and
& Apos; 'single quotes
& Quot; "Double quotation marks

The object must start with the symbol "&" and end with the symbol.

Note: only "<" and "&" characters are strictly forbidden for XML . The rest are legal. It is a good habit to use entities to reduce errors.

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: 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.