HTML inside xml tag

You can include HTML inside XML tag using CDATA container. Aand strip that HTML using javascript to show up in html page dynamically.

<?xml version="1.0" encoding="utf-8"?>
<MyXML>
  <TextElement>This is text</TextElement>
  <HTMLElement><![CDATA[<div>your html here</div>]]></HTMLElement>
</MyXML>

Strip it using Javascript Jquery.

$xml = $($.parseXML(myxml));
$htmlTag = $xml.find("HTMLElement").text();
$PuerHtml = $htmlTag.replace("<![CDATA[", "").replace("]]>", "");
alert($PureHTML);


Tags: Xml, Javascript, Html