Why should you use XML CDATA blocks?

前端 未结 2 938
借酒劲吻你
借酒劲吻你 2021-01-19 13:31

When creating XML I\'m wondering why the CDATA blocks are uses rather than just escaping the data. Is there something allowed in a CDATA block that can\'t be escaped and pla

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-19 13:42

    It's first and most of all readability feature. XML, and SGML before it were originally meant to be human readable - believe it or not :-))

    Second, for a good parser it's a perf feature. The ]]> ending is guaranteed to be the actual block ending but apart from that it's a blob.

    By the book parser should also keep the info/attrib on a node representation to track that it has explicit CDATA and never ever touch a single char in it.

提交回复
热议问题