Special character processing for XML

Source: Internet
Author: User
Tags xml parser

There are 5 special characters in the XML, namely,:&<> "'. If the injected value in the configuration file includes these special characters, special processing is required. There are two workarounds: first, the <! in this example [cdata[]]> Special tags, wrapping strings containing special characters, and second, using XML escape sequences to represent these special characters, the corresponding XML escape sequences for these 5 special characters are described in table 4-2:

When spring is in the XML configuration, if the property value contains a special symbol for the XML, we deliberately add a <! outside the property value. [cdata[]]> 's XML special handling tag, <! [cdata[]]> 's role is to have the XML parser treat the string in the tag as plain text to prevent some strings from damaging the XML format. Take a look at an example:

XML code
    1. <Bean id="code" class="cn.easypm.www">
    2. <property name="Maxspeed">
    3. <value>200</value>
    4. </Property>
    5. <property name="brand">
    6. <value><![ cdata[easypm&ca72]]></value>
    7. </Property>
    8. </Bean>

Special character processing for XML

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.