Best Practices for Using HTML / XHTML Content in XML Elements
I would recommend CDATA; this will make XML more compact and human readable.
However, make sure you choose ]]>
how ]]>]]<![CDATA[
.
EDIT . As other people have said, if you are in control of the HTML you embed and you know it will always be valid XHTML, then you should embed it directly without leaving it.
However, if you are not in control of HTML, I do not recommend doing this. Even if it is valid now, it may become invalid one day, and you don't want your system to suddenly crash because of it. Obviously, this depends on the circumstances and the precedent; if you would like a more precise recommendation, please let us know in more detail.
source to share
Option three: HTML, usually embedded in XML, is much more flexible than encoding it or embedding it in CDATA. This allows parsers to parse the entire document, including HTML, at a high level. It allows you to use XSL transformations on both containing XML and HTML data.
So, I suggest to directly embed it if your HTML is not valid XML, in which case encoding or CDATA would be the only option.
source to share
Since a lot of HTML is not well-formed as XML (ie missing end tags such as </p>, </li>, and <br />), it may be less work to simply use a CDATA wrapper.
It depends on where you get the HTML from. If you create it yourself, you have complete control over its shape, but if you pull it from some other source (for example, by pulling it from some other website) you probably won't have the luxury of reformatting it not to be XHTML compliant.
source to share