JS读取XML文件的方法

来源:互联网 发布:美图手机抢购软件 编辑:程序博客网 时间:2024/03/28 17:40
<pre name="code" class="javascript">//获取xml文件function loadXmlFile(xmlFile){  var xmlDom = null;  if (window.ActiveXObject){    xmlDom = new ActiveXObject("Microsoft.XMLDOM");xmlDom.async=false;   xmlDom.load(xmlFile)||xmlDom.loadXML(xmlFile);//如果用的是XML字符串//如果用的是xml文件  }else if (document.implementation && document.implementation.createDocument){    var xmlhttp = new window.XMLHttpRequest();    xmlhttp.open("GET", xmlFile, false);    xmlhttp.send(null);    xmlDom = xmlhttp.responseXML;  }else{    xmlDom = null;  }  return xmlDom;}//判断子节点为不为空function isnull(obj){var nodevalue = "";if(obj.childNodes[0] != null){nodevalue =obj.childNodes[0].nodeValue;}return nodevalue;}var stringsss="";//获得页面内容function getContent(content){//exBrows();var val = encodeURI(content);orderDoc=loadXmlFile("http://www.tuling123.com/openapi/productexp.do?info="+val);items=isnull(orderDoc.getElementsByTagName("Content")[0]);//.nodeValue;}


var div = document.getElementById("chat_message");div.scrollTop = div.scrollHeight; 



0 0
原创粉丝点击