<html>
<head>
<p id="dmd">
Click button for create CDATASelectio</p>
<script type="text/javascript">
function myfun() {
var http;
if (window.XMLHttpRequest) { VHF = new XMLHttpRequest(); }
else { VHF = new ActiveXObject("Microsoft.XMLHTTP"); }
VHF.open("GET", "abc.xml", false);
VHF.send();
var xmlDoc = VHF.responseXML;
var cost = xmlDoc.getElementsByTagName("Cost")[0];
var txt = "Before adding the CDATASection<br>";
txt = txt + cost.childNodes[0].nodeValue;
var cdat = xmlDoc.createCDATASection(" 55.90");
cost.appendChild(cdat);
txt = txt + "<br>After Adding CDATASelection<br>"
txt = txt + cost.childNodes[0].nodeValue;
txt = txt + cost.childNodes[1].nodeValue;
document.getElementById("dmd").innerHTML = txt;
};
</script>
</head>
<body>
<button onclick="myfun()">
click me</button>
<p>
CDATASelection only work for xml and its not work in html</p>
</body>
</html>
|