日期:2014-05-16 浏览次数:20361 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Read XMLData</title> <script type="text/javascript"> var loadXML = function (path, callback) { if (window.ActiveXObject) { var xml = new window.ActiveXObject('Microsoft.XMLDOM'); xml.async = false; xml.load(path); callback(xml); } else if (document.implementation && document.implementation.createDocument) { var xml = document.implementation.createDocument("", "", null); xml.load(path); xml.onload = function () { callback(xml); }; } }; window.onload = function () { loadXML('xml.xml', function (xml) { var datas = xml.getElementsByTagName('MenuNode'), htmls = [], i = 0, t, l; for (l = datas.length ; i < l ; i ++) { t = datas[i], htmls[htmls.length] = '<a href="' + t.getAttribute('Url') + '"><img src="' + t.getAttribute('NormalPath') + '" alt="' + t.getAttribute('OnTips') + '" onmouseover="this.src=\'' + t.getAttribute('OverPath') + '\'" onmouseout="this.src=\'' + t.getAttribute('NormalPath') + '\'" \/><\/a>'; } document.getElementById('data').innerHTML = htmls.join('<br \/>'); }); }; </script> </head> <body> <div id="data"></div> </body> </html>