XML文档写入数据和修改数据不成功会有哪些原因?(代码如下)
//IE6 8 ff都存在这个问题,求高人解答!不甚感激!!
xml_Hpage = loadXML("config.xml");
x = xml_Hpage.getElementsByTagName("ph")[0];
x.setAttribute("id", "0");//测试了下xml文档里没变,什么问题??
newNode = xml_Hpage.createElement("txt");//创建读取数据都是成功的,添加和修改xml文档没反应
newNode.setAttribute("id", "0");
newNode.setAttribute("d_name", sName);
newNode.setAttribute("imgurl", imgUrl);
newNode.setAttribute("durl", sUrl);
x.appendChild(newNode);
function loadXMLDoc(dname) {//xml文档载入
try //Internet Explorer
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
}
catch (e) {
try //Firefox, Mozilla, Opera, etc.
{
xmlDoc = document.implementation.createDocument("", "", null);
}
catch (e) { alert(e.message) }
}
try {
xmlDoc.async = false;
xmlDoc.load(dname);
return (xmlDoc);
}
catch (e) { alert(e.message) }
return (null);
}