Is it possible to insert HTML content in XML document?

前端 未结 4 1762
粉色の甜心
粉色の甜心 2020-12-02 09:48

I need to insert HTML content into an XML document, is this possible or should HTML content be, for example, encoded in BASE64 or with something else like that?

4条回答
  •  猫巷女王i
    2020-12-02 10:05

    The purpose of BASE64 encoding is to take binary data and be able to persist that to a string. That benefit comes at a cost, an increase in the size of the result (I think it's a 4 to 3 ratio). There are two solutions. If you know the data will be well formed XML, include it directly. The other, an better option, is to include the HTML in a CDATA section within an element within the XML.

提交回复
热议问题