【发布时间】:2014-09-14 10:07:21
【问题描述】:
document.write(x[i].getElementsByTagName("property")[0].childNodes[0].nodeValue);
当它没有得到任何价值时,它就会停止工作。 这是一个for循环:
var x=xmlDoc.getElementsByTagName("object");
for (i=0;i<x.length;i++)
{
document.write("<table border='1'>");
document.write("<tr><td>Last Communication</td><td>");
document.write(x[i].getElementsByTagName("property")[0].childNodes[0].nodeValue);
我该怎么办?
【问题讨论】:
-
所以在写之前检查
x[i].getElementsByTagName("property")[0].childNodes[0].nodeValue的值 -
for (i=0;i
-
不要像这样使用
document.write。最好不要使用document.write。如果您不知道自己在做什么,它有多个难以避免的问题。在任何情况下总是一次写入完整的元素(从开始到结束标记),将所有内容放在一个字符串中并在末尾使用一次document.write。
标签: javascript html xml dom