问一个很弱质的问题呐,在FF,NS等浏览器上如何创建XML对象来操作XML呐???汗~~

解决方案 »

  1.   

    有意思的问题。
    最近在搞XML。
    这个是浏览器兼容性问题而已。
      

  2.   

    樓主的問題,看看msdn就知道答案了。msdn .net 2003.
      

  3.   

    Microsoft.XMLHTTPMany 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: &lt;, &amp;, &gt;, &quot;, and &apos;.這個你應該看得懂的吧,大哥
      

  4.   

    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文的说明了
      

  5.   

    不知道你们有没有用过微软的XML查看器,微软有的下的,E文的,你下来后,运行(web形式)的,你就会发现自己机器上有很多关于XML的版本装着,看了后你就知道,为什么有那么名字了
      

  6.   

    <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>
      

  7.   

    这其实应该放到XML版去。new ActiveXObject("Microsoft.XMLHTTP");
    默认版本的XMLHTTP,XMLHTTP主要用来传输数据。new ActiveXObject("MSXML2.ServerXMLHTTP");
    SERVER XMLHTTP,是从XMLHTTP派生的,详细区别,查找MSXML SDK里ServerXMLHTTP,上面有说明。new ActiveXObject('MSXML');
    这个用法好象没有,好象也不会有这样调用插件的。new ActiveXObject("Microsoft.XMLDOM");
    默认的XMLDOMnew 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");
    这个版本似乎还没发行。
      

  8.   

    对,这些对象搞得人头晕.搞一个统一的不就行了?搞那么多相似的干嘛呀,让人不知所措.-------------------------------------------------------
     yefeng119(呵仆呵仆)
    "不知道你们有没有用过微软的XML查看器,微软有的下的,E文的,你下来后,运行(web形式)的,你就会发现自己机器上有很多关于XML的版本装着,看了后你就知道,为什么有那么名字了"
    ------------------------------------------------------
    在哪有得下呀.我找不到,贴个url出来好吗