日期:2014-05-16  浏览次数:20512 次

火狐读 xml 出问题
if (window.navigator.appName == "Microsoft Internet Explorer") {
  doc = new ActiveXObject("Microsoft.XMLDOM");
  doc.async = "false";
  doc.load("myXML.xml");
  var nodes = doc.documentElement.childNodes;
  var nodes = doc.getElementsByTagName("student");
  var ul = document.createElement("ul");
  for (var i = 0; i < nodes.length; i++) {
  var li = document.createElement("li");
  li.innerText = nodes[i].text;
  ul.appendChild(li);
  }
  document.getElementById("myTable").appendChild(ul);
  }
  //火狐 
  else if (window.navigator.appName == "Netscape") {
  doc = document.implementation.createDocument("", "", null);
  doc.load("myXML.xml");
  doc.onload = function () {

  var nodes = doc.getElementsByTagName("student");
  var ul = document.createElement("ul");
  for (var i = 0; i < nodes.length; i++) {
  var li = document.createElement("li");
  alert(nodes[i].nodeValue);
  li.innerText = nodes[i].text;//出问题了[b][/b]
  ul.appendChild(li);
  }
  document.getElementById("myTable").appendChild(ul);

  };
  }

<?xml version="1.0" encoding="utf-8" ?>
<students>
  <student>s1</student>
  <student>s2</student>
  <student>s3</student>
  <student>s4</student>
</students>

------解决方案--------------------
nodes[i].nodeValue 
试试