What are invalid characters in XML

后端 未结 15 1342
时光说笑
时光说笑 2020-11-22 03:23

I am working with some XML that holds strings like:

This is a string

Some of the strings that I am passing to the

15条回答
  •  灰色年华
    2020-11-22 04:07

    In summary, valid characters in the text are:

    • tab, line-feed and carriage-return.
    • all non-control characters are valid except & and <.
    • > is not valid if following ]].

    Sections 2.2 and 2.4 of the XML specification provide the answer in detail:

    Characters

    Legal characters are tab, carriage return, line feed, and the legal characters of Unicode and ISO/IEC 10646

    Character data

    The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings " & " and " < " respectively. The right angle bracket (>) may be represented using the string " > ", and must, for compatibility, be escaped using either " > " or a character reference when it appears in the string " ]]> " in content, when that string is not marking the end of a CDATA section.

提交回复
热议问题