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

求firefox中,遍历table的脚本,谢谢!!!!!!!!!!!
求firefox中,遍历table的脚本,谢谢!!!!!!!!!!!

------解决方案--------------------
解析xml文件
<html>
<head>
<script type= "text/javascript ">
var xmlDoc;
function loadXML()
{
//load xml file
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject( "Microsoft.XMLDOM ");
xmlDoc.async=false;
xmlDoc.load( "note.xml ");
getmessage();
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument( " ", " ",null);
xmlDoc.load( "note.xml ");
xmlDoc.onload=getmessage;
}
else
{
alert( 'Your browser cannot handle this script ');
}
}

function getmessage()
{
document.getElementById( "to ").innerHTML=xmlDoc.getElementsByTagName( "to ")[0].childNodes[0].nodeValue;
document.getElementById( "from ").innerHTML=xmlDoc.getElementsByTagName( "from ")[0].childNodes[0].nodeValue;
document.getElementById( "message ").innerHTML=xmlDoc.getElementsByTagName( "body ")[0].childNodes[0].nodeValue;
}
</script>
</head>

<body onload= "loadXML() ">
<h1> W3Schools Internal Note </h1>
<p> <b> To: </b> <span id= "to "> </span> <br />
<b> From: </b> <span id= "from "> </span> <br />
<b> Message: </b> <span id= "message "> </span>
</p>
</body>
</html>


解析xml字符串
<html>
<body>

<script type= "text/javascript ">

var text= " <note> ";
text=text+ " <to> Tove </to> ";
text=text+ " <from> Jani </from> ";
text=text+ " <heading> Reminder </heading> ";
text=text+ " <body> Don 't forget me this weekend! </body> ";
text=text+ " </note> ";

// code for IE
if (window.ActiveXObject)
{
var doc=new ActiveXObject( "Microsoft.XMLDOM ");
doc.async= "false ";
doc.loadXML(text);
}
// code for Mozilla, Firefox, Opera, etc.
else
{
var parser=new DOMParser();
var doc=parser.parseFromString(text, "text/xml ");
}

var x=doc.documentElement;

document.write( "Text of first child element: ");
document.write(x.childNodes[0].childNodes[0].nodeValue);
document.write( " <br /> ");
document.write( "Text of second child element: ");
document.write(x.childNodes[1].childNodes[0].nodeValue);

</script>

</body>
</html>