各位:写错了,
重新发一次:
html和js如下js如下:
<html>
<head>
</head>
<body> <script type="text/javascript"> xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(此处是上面的xml文件);
document.write(xmlDoc.documentElement.nodeName);
document.write(" <br />");
document.write(xmlDoc.documentElement.nodeType);
</script>
</body>
</html>
重新发一次:
html和js如下js如下:
<html>
<head>
</head>
<body> <script type="text/javascript"> xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(此处是上面的xml文件);
document.write(xmlDoc.documentElement.nodeName);
document.write(" <br />");
document.write(xmlDoc.documentElement.nodeType);
</script>
</body>
</html>
<title lang="en">Harry Potter </title>
<author>J K. Rowling </author>
<year>2005 </year>
<price>29.99 </price>
</book> 好象是不提倡写成这样的吧 我暂时看到的资料上都是这么说的<book >
<category>children</category>
<title lang="en">Harry Potter </title>
<author>J K. Rowling </author>
<year>2005 </year>
<price>29.99 </price>
</book> xmlDoc.getElementsByTagName("str")[i].childNodes[0].nodeValue
str是子元素的名字 i指的是第几个str 从0开始
childNodes[0]是str的子元素
红色的地方该怎么把属性写出来我也没见过 得请大虾请教