demo用了点extjs的东西,主要是为了打印json数组出来。 js code(XmlUtils.js): 代码如下:/**/ function XmlUtils (config) { /*定义私有属性*/ this.isIE = !!(window.attachEvent && !window.opera); this.init(); if(config) { this.dataType = config.dataType == json ? json : array; if(config.xmlPath) this.loadXml(config.xmlPath); } } XmlUtils.prototype = { xmlDoc : null, xmlPath : null, dataType : null, /** * ...
前台: 代码如下:<!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> <title>js操作Xml(向服务器发送Xml,处理服务器返回的Xml)(IE下有效)</title> <script type="text/javascript"><!-- var xmlHttp = null;//XmlHttp对象,Ajax核心 //创建一个Xml文档,向服务器发送. function f(){ var xmlDoc = n...
看了一天的XML资料,感觉CSDN上这篇讲的挺细致的。即有Dot Net写入XML文件的示例,又有JS读取的示例,值得一看。(Source:http://blog.csdn.net/flypigluo) 一.本笔记使用的Xml文件 二.IXMLDOMDocument/DOMDocument简介 2.1 属性 2.1.1 parseError 2.1.2 async. 2.1.3 xml 2.1.4 text3 2.1.5 attributes 2.1.6 nodeName 2.1.7 documentElement 2.1.8 nextSibling 2.1.9 childNodes 2.1.10 ...
文中尽量用上所有的操作和属性,以做示范 代码如下:<script language="JavaScript"> <!-- var doc = new ActiveXObject("Msxml2.DOMDocument"); //ie5.5+,CreateObject("Microsoft.XMLDOM") //加载文档 //doc.load("b.xml"); //创建文件头 var p = doc.createProcessingInstruction("xml","version=1.0 encoding=gb2312"); //添加文件头 doc.appendChild(p); //用于直接加载时获得根接点 //var root = doc.do...