JavaScript Window对象Cdataselection()方法示例
<html>
<head>
Click button for create CDATASelectio
<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()">点击</button>
<p>CDATA选择只适用于xml,不适用于html
</p>
</body>
</html>
在本文中,我将在JavaScript中解释DOM Object CreateCdataselection()方法。
JavaScript Window对象Cdataselection()方法
JavaScript CdataseLection()方法用于创建给定细节文本的CDataSelection节点。
语法
xmlData.CreateCDATASelection("Some text")
日期:2020-04-11 23:04:37 来源:oir作者:oir
