XML Special character processing

Source: Internet
Author: User

Common sense to write XML code that is often omitted:

Special characters such as "&", "<", ">" are not allowed in the XML entity, or an error occurs when the XML syntax is checked, and if you write an XML file that must contain these characters, it must be written as "&amp;", "&lt;", "&gt;" To write to the file again.

For example, if you use a character like "<" in an XML document, the parser will get an error because the parser will assume that this is the beginning of a new element.

Therefore, you should not write the code as follows:

When reading, the parser automatically converts it back to special characters such as "&", "<", ">", and, normally, only the "<" character and "&" characters are strictly forbidden for XML.
It is important to note that:
A. There can be no spaces between the characters of the escape sequence;
B. The escape sequence must end with ";";
C. Individual & is not considered to be an escape start;
D. Case sensitive.


The following are the required escape characters in XML: [/size]
& (Logic and) &amp;
< (less than) &lt;
> (greater than) &gt;
"(double quotes) &quot;
' (single quotes) &apos;
[/size]

XML Special character processing

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.