js中操作xml有很多的ActiveXObject,它们本质上有何不同,操作上有什么区别呢?

梅雪香 2005-10-30 08:17:57
js中操作xml有很多的ActiveXObject,它们本质上有何不同,操作上有什么区别呢?

new ActiveXObject("Microsoft.XMLHTTP");
new ActiveXObject("MSXML2.ServerXMLHTTP");
new ActiveXObject('MSXML');
new ActiveXObject("Microsoft.XMLDOM");
new ActiveXObject("MSXML2.DOMDocument");
new ActiveXObject("Msxml2.DOMDocument.2.0");
new ActiveXObject("Msxml2.DOMDocument.3.0");
new ActiveXObject("MSXML2.DOMDocument.4.0");
new ActiveXObject("Msxml2.DOMDocument.5.0");

看的人头晕~!~
...全文
391 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
梅雪香 2005-11-05
  • 打赏
  • 举报
回复
up
donghid 2005-11-04
  • 打赏
  • 举报
回复
对,这些对象搞得人头晕.搞一个统一的不就行了?搞那么多相似的干嘛呀,让人不知所措.

-------------------------------------------------------
yefeng119(呵仆呵仆)
"不知道你们有没有用过微软的XML查看器,微软有的下的,E文的,你下来后,运行(web形式)的,你就会发现自己机器上有很多关于XML的版本装着,看了后你就知道,为什么有那么名字了"
------------------------------------------------------
在哪有得下呀.我找不到,贴个url出来好吗
cds27 2005-11-01
  • 打赏
  • 举报
回复
这其实应该放到XML版去。

new ActiveXObject("Microsoft.XMLHTTP");
默认版本的XMLHTTP,XMLHTTP主要用来传输数据。

new ActiveXObject("MSXML2.ServerXMLHTTP");
SERVER XMLHTTP,是从XMLHTTP派生的,详细区别,查找MSXML SDK里ServerXMLHTTP,上面有说明。

new ActiveXObject('MSXML');
这个用法好象没有,好象也不会有这样调用插件的。

new ActiveXObject("Microsoft.XMLDOM");
默认的XMLDOM

new ActiveXObject("MSXML2.DOMDocument");
XML DOM 1。0版?好象是默认的XML DOM版本,我不确定。

new ActiveXObject("Msxml2.DOMDocument.2.0");
XML DOM 2。0版

new ActiveXObject("Msxml2.DOMDocument.3.0");
XML DOM 3。0版

new ActiveXObject("MSXML2.DOMDocument.4.0");
XML DOM 4。0版

new ActiveXObject("Msxml2.DOMDocument.5.0");
这个版本似乎还没发行。
uumlwy 2005-11-01
  • 打赏
  • 举报
回复
俺也是E文高手,就是没时间看啊,嘿嘿
公司每天都要培训E文,就是给的工资低,我哭!
梅雪香 2005-11-01
  • 打赏
  • 举报
回复
<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.documentElement;

//两种方式创建根接点
// var root = doc.createElement("students");
var root = doc.createNode(1,"students","");

//创建子接点
var n = doc.createNode(1,"ttyp","");

//指定子接点文本
//n.text = " this is a test";

//创建孙接点
var o = doc.createElement("sex");
o.text = "男"; //指定其文本

//创建属性
var r = doc.createAttribute("id");
r.value="test";

//添加属性
n.setAttributeNode(r);

//创建第二个属性
var r1 = doc.createAttribute("class");
r1.value="tt";

//添加属性
n.setAttributeNode(r1);

//删除第二个属性
n.removeAttribute("class");

//添加孙接点
n.appendChild(o);

//添加文本接点
n.appendChild(doc.createTextNode("this is a text node."));

//添加注释
n.appendChild(doc.createComment("this is a comment\n"));

//添加子接点
root.appendChild(n);

//复制接点
var m = n.cloneNode(true);

root.appendChild(m);

//删除接点
root.removeChild(root.childNodes(0));

//创建数据段
var c = doc.createCDATASection("this is a cdata");
c.text = "hi,cdata";
//添加数据段
root.appendChild(c);

//添加根接点
doc.appendChild(root);

//查找接点
var a = doc.getElementsByTagName("ttyp");
//var a = doc.selectNodes("//ttyp");

//显示改接点的属性
for(var i= 0;i<a.length;i++)
{
alert(a[i].xml);
for(var j=0;j<a[i].attributes.length;j++)
{
alert(a[i].attributes[j].name);
}
}

//修改节点,利用XPATH定位节点
var b = doc.selectSingleNode("//ttyp/sex");
b.text = "女";

//alert(doc.xml);

//XML保存(需要在服务端,客户端用FSO)
//doc.save();

//查看根接点XML
if(n)
{
alert(n.ownerDocument.xml);
}

//-->
</script>
friendlyFour 2005-11-01
  • 打赏
  • 举报
回复
yefeng119 2005-11-01
  • 打赏
  • 举报
回复
不知道你们有没有用过微软的XML查看器,微软有的下的,E文的,你下来后,运行(web形式)的,你就会发现自己机器上有很多关于XML的版本装着,看了后你就知道,为什么有那么名字了
yefeng119 2005-11-01
  • 打赏
  • 举报
回复
new ActiveXObject("Msxml2.XMLHTTP");是通用的,但用的是客户端,的机器上装用。XML2.0,3.0,4.0,5.0,5.1,用new ActiveXObject("Msxml2.XMLHTTP");就是全通用,其他new ActiveXObject("MSXML2.DOMDocument.4.0"); 就是对应的版本问题,new ActiveXObject("MSXML2.ServerXMLHTTP");是调用服务端的XML!


另外小弟对XML也不懂,但是就知道他们的用途,哈哈,偶尔用用XMLHTTP,不懂就看E文的说明了
梅雪香 2005-11-01
  • 打赏
  • 举报
回复
怎么就没有人来说个明白呢?
csdntzg 2005-10-31
  • 打赏
  • 举报
回复
学习,关注
csdntzg 2005-10-31
  • 打赏
  • 举报
回复
学习,关注
fantiny 2005-10-31
  • 打赏
  • 举报
回复
Microsoft.XMLHTTP

Many of the examples in this section use an instance of the Microsoft.XMLHTTP Component Object Model (COM) class to send and receive WebDAV requests to the Exchange store. In addition, many examples use an instance of the Microsoft.XMLDOM COM component to construct and manipulate the Extensible Markup Language (XML) bodies that are used for WebDAV protocol requests. The XMLHTTP COM object is part of the Microsoft XML (MSXML) 2.0 or later COM component and integrates directly with the other components. For example, you can retrieve the XML body of a successful PROPFIND Method directly from the XMLHTTP object as a DOMDocument object.

Use the XMLHTTP COM class only on clients. If you are creating applications on the server where the Exchange store is located, use the ServerXMLHTTP COM class or the Exchange OLE DB (ExOLEDB) provider.

When manually constructing the XML body of a WebDAV request, caution must be used with certain characters. Some special characters are reserved for use by XML, so they cannot be directly used in the XML text. These characters, <, &, >, ", and ' must be substituted with the following character codes, respectively: <, &, >, ", and '.

這個你應該看得懂的吧,大哥
孔南 2005-10-31
  • 打赏
  • 举报
回复
我也想知道~~~ 顶.
梅雪香 2005-10-31
  • 打赏
  • 举报
回复
都是E文,看不懂的啊
fantiny 2005-10-31
  • 打赏
  • 举报
回复
樓主的問題,看看msdn就知道答案了。msdn .net 2003.
zhiin1 2005-10-31
  • 打赏
  • 举报
回复
这么好的贴子怎么能沉?

顶一下 :-)
moodboy1982 2005-10-30
  • 打赏
  • 举报
回复
有意思的问题。
最近在搞XML。
这个是浏览器兼容性问题而已。
matrixy 2005-10-30
  • 打赏
  • 举报
回复
问一个很弱质的问题呐,在FF,NS等浏览器上如何创建XML对象来操作XML呐???

汗~~
zhiin1 2005-10-30
  • 打赏
  • 举报
回复
顶一下~

关键是如何来实现不同浏览器的兼容!

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧