What does <![CDATA[]]> in XML mean?

前端 未结 13 2178
独厮守ぢ
独厮守ぢ 2020-11-21 07:52

I often find this strange CDATA tag in XML files:


I have observed that this CD

13条回答
  •  情书的邮戳
    2020-11-21 08:13

    Note that the CDATA construct is only needed if placing text directly in the XML text file.

    That is, you only need to use CDATA if hand typing or programmatically building the XML text directly.

    Any text entered using a DOM processor API or SimpleXML will be automatically escaped to prevent running foul of XML content rules.

    Notwithstanding that, there can be times where using CDATA can reduce the text size that would otherwise be produced with all entities encoded, such as for css in style tags or javascript in script tags, where many language constructs use characters in HTML|XML, like < and >.

提交回复
热议问题