慕尼黑的夜晚无繁华
1 对这个xml文件的内容进行操作2 首先,加载这个xml文件,js中加载xml文件,是通过XMLDOM来进行的.// 加载xml文档loadXML = function(xmlFile){var xmlDoc;if(window.ActiveXObject){xmlDoc = new ActiveXObject('Microsoft.XMLDOM');xmlDoc.async = false;//是否异步加载xml文件(如果为ture,程序不论xml文件是否全部载入就开始运行下面程序,所以如果接下来就操作xml文件可能出错)xmlDoc.load(xmlFile);}else if (document.implementation&&document.implementation.createDocument){xmlDoc = document.implementation.createDocument('', '', null);xmlDoc.load(xmlFile);}else{return null;}return xmlDoc;}xml文件对象出来了, 接下去要对这个文档进行操作了比如说,需要得到节点Login/Weapon/W的第一个节点的属性,那么可以如下进行:// 首先对xml对象进行判断checkXMLDocObj = function(xmlFile){var xmlDoc = loadXML(xmlFile);if(xmlDoc==null){alert('您的浏览器不支持xml文件读取,于是本页面禁止您的操作,推荐使用IE5.0以上可以解决此问题!');window.location.href='/Index.aspx';}return xmlDoc;}// 然后开始获取需要的Login/Weapon/W的第一个节点的属性值var xmlDoc = checkXMLDocObj('/EBS/XML/Login.xml');var v = xmlDoc.getElementsByTagName('Login/Weapon/W')[0].childNodes.getAttribute('Text')