Processing of special characters in XML files

Source: Internet
Author: User
Original article address:Processing of special characters in XML files Author:Spiritual journey

processing special characters in XML files
in XML, all valid characters between the start and end tags are faithfully passed to the XML processing Program . To avoid confusion between character data and some special symbols used in tags, XML also provides some useful entity references. Object references are replaced by object references when these special symbols are needed in character data. These special XML Entity references include:

& gt;

<;

& amp;

"& quot;

'& apos;

in this way, if we need to show text in the "example" Mark

" Zhang San "

correct syntax yes:

example> & lt; Name & gt; Zhang San & lt;/Name & gt;

easy to understand, the entity reference of the character "<" is essential. For ">", entity reference is also set up to avoid confusion with Mark, the object reference of the character "&" prevents it from being confused with the "&" used in the header in the object reference. So when do we need to use entity references with the remaining two characters? In the tag, you can set attributes for the tag, and XML requires that the attribute values be included in. Therefore, when the character "appears in the attribute value, it must be replaced by an entity reference. See the following example:

correct syntax:


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.