XML parsing file error solution: What is xml cdata?

Source: Internet
Author: User
Tags printable characters xml cdata

XML parsing often fails because the file contains special characters. There are two reasons: first, the content contains an XML predefined entity, and second, the content contains low-level non-printable characters.

1. the content contains the objects pre-defined in XML, such as "<" and "&", which are forbidden for XML. For such characters, the solution is to use the CDATA component to "<! The [CDATA ["Mark starts with"]> "Mark ends. The internal content of CDATA is ignored by the parser. For more information, see what is xml cdata?

2. If the content contains low-level non-printable characters, an error will be reported during parsing.: "" (Hexadecimal value 0x1d) is an invalid character. exception thrown when loading or saving XML. system. argumentexception: "" (hexadecimal value 0x1d) is invalid character.

The error occurs because the content contains low-level non-printable characters. The processing method is to filter the low-level non-printable characters. The filtering method is as follows:

ReturnSystem. Text. regularexpressions. RegEx. Replace (STR ,@"[\ X00-\ x08] | [\ x0b-\ x0c] | [\ x0e-\ x1f]";

For more information, see XML file error solution! (Transfer).

The first case is more common, and the second case is less common. In the face of some user input data, XML can be generated to filter the content of XML nodes, to ensure that users of XML files can parse XML documents correctly.

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.