<html>
<head>
<script type="text/javascript" src="loadxmldoc.js">
</script>
</head>
<body>
<script type="text/javascript">
xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName('book');
var newel,newtext
for (i=0;i<x.length;i++)
{
newel=xmlDoc.createElement('edition');
newtext=xmlDoc.createTextNode('First');
newel.appendChild(newtext);
x[i].appendChild(newel);
}
//Output all titles and editions
var y=xmlDoc.getElementsByTagName("title");
var z=xmlDoc.getElementsByTagName("edition");
for (i=0;i<y.length;i++)
{
document.write(y[i].childNodes[0].nodeValue);
document.write(" - Edition: ");
document.write(" <br/>");
document.write(z[i].childNodes[0].nodeValue);
document.write("<br />");
}
</script>
</body>
</html>
w3c直接复制的,可以在html里显示更改但是xml文件中依然不变
那就是说它就只有浏览功能吧,那有什么意义
追答意义大了呀,Web一直都不能修改本地文件——除了微软的IE——可这显然没有妨碍Web的飞速发展。顺便一提,Html5曾经一度考虑过引入“文件API”,以允许JS程序在极度受限的环境下修改本地文件,但最终W3C否决了文件API,所以预计在未来相当长的时间里,都不会有符合标准的、跨浏览器的修改本地文件的方法。