How to: Embed HTML within XML

I spent some time today trying to figure out how to embed HTML within XML. This would obviously be an issue. When the XML would be parsed, the parser would easily mistaken the HTML tags as child XML tags.

I thought using urencode() or perhaps replacing all ‘<' and '>‘ with < and >. Then it hit me, the XML standard should have thought about this. So I checked the XML 1.0 standard. They did have a solution (remove spaces):

CDATA sections begin with the string ” < ! [C D A T A [ " and end with the string " ] ] >“

Related Articles:

6 Responsesto “How to: Embed HTML within XML”

  1. Bernard says:


    Thanks this helped me solve a problem of xsl stripping from the data of a node.

  2. Bernard says:

    I was saying the xsl was stripping <br /> (html breaks) from the data of a node.

  3. Aitor Elfau says:

    Thank you,

    very concise and helpful.

  4. paleo diet lifestyle says:

    I love the precious details you actually offer your content. I’m going to book mark a person’s website and view again right here frequently. We’re sensibly specified I will be told numerous new goods listed here! All the best for the next!

  5. says:

    Excellent publish. I became verifying frequently this site and i am influenced! Very beneficial data precisely the segment :) I personally deal with these information a whole lot. I used to be seeking this particular details to get a period of time. Thanks a lot as well as enjoy.

  6. decoracion de discotecas says:

    Hiya, basically become responsive to your blog site as a result of Yahoo and google, and located that it’s definitely helpful. I am just likely to look for belgium’s capital. Let me value if you commence the following in the future. Many people may be achieved positive results out of your publishing. Regards!

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>