日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

xpath IE 7

發布時間:2025/4/16 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 xpath IE 7 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、

https://msdn.microsoft.com/zh-cn/library/ms756048(v=vs.85).aspx

?

XML內容(example.xml):

1 <?xml version="1.0"?> 2 <root> 3 <branch>branch</branch> 4 <a:root xmlns:a="http://myserver.com"> 5 <a:branch>a-branch</a:branch> 6 <b:branch xmlns:b="http://yourserver.com"> 7 b-branch 8 </b:branch> 9 </a:root> 10 </root>

?

JS 代碼:

1 window.onload = function() 2 { 3 //* 4 var dom = new ActiveXObject("MSXML2.DOMDocument.6.0"); 5 dom.async= false; 6 dom.validateOnParse = false; 7 //dom.load("example.xml"); // 加載 xml文件 8 dom.loadXML(g_strXML);  // 加載 xml字符串 9 if (dom.parseError.errorCode!=0) 10 { 11 alert("can't load dom" + dom.parseError.reason); 12 exit; 13 } 14 //*/ 15 console.log("dom : '"+dom+"' , "+typeof dom); 16 /* for (var z in dom) // ZC: 這個dom不能使用這個方式取得它的屬性/方法,會報錯:"對象不支持此操作" 17 { 18 console.log(z); 19 } 20 //*/ 21 //* // *** *** *** 22 ns = "xmlns:na='http://myserver.com' xmlns:nb='http://yourserver.com'"; 23 24 console.log("ns:(before setProperty())\n "+dom.getProperty("SelectionNamespaces")); // DOMParser不能使用這種方式來檢索帶命名空間的節點,∵它只有一個方法 parseFromString,沒有getProperty/setProperty方法 25 console.log(""); 26 27 dom.setProperty("SelectionNamespaces", ns); 28 console.log("ns:(after setProperty())\n "+dom.getProperty("SelectionNamespaces")); 29 console.log(""); 30 31 node = dom.selectSingleNode("//root"); 32 console.log("root: \n"+node.xml); 33 //alert("root: \n"+node.xml); 34 console.log(""); 35 36 node = dom.selectSingleNode("//na:root"); 37 console.log("a:root: \n"+node.xml); 38 console.log(""); 39 40 node = dom.selectSingleNode("//branch"); 41 console.log("branch: \n"+node.xml); 42 console.log(""); 43 44 node = dom.selectSingleNode("//na:branch"); 45 console.log("a:branch: \n"+node.xml); 46 console.log(""); 47 48 node = dom.selectSingleNode("//nb:branch"); 49 console.log("b:branch: \n"+node.xml); 50 //alert("b:branch: \n"+node.xml); 51 //*/ 52 };

?

輸出:

“console.log("dom : '"+dom+"' , "+typeof dom);”的輸出為:

日志: dom : '' , object

?

其他輸出為(alert的輸出,是和下面的值一樣的。但是,IE7的console打印出來的值,每次console.log的信息最后都會燒掉一些...):

1 ns:(before setProperty()) 2 ns:(after setProperty()) 3 xmlns:na='http://myserver.com' xmlns:nb='http://yourserver.com' 4 5 root: 6 <root> 7 <branch>branch</branch> 8 <a:root xmlns:a="http://myserver.com"> 9 <a:branch>a-branch</a:branch> 10 <b:branch xmlns:b="http://yourserver.com"> 11 b-branch 12 </b:branch> 13 </a:root> 14 </root> 15 16 a:root: 17 <a:root xmlns:a="http://myserver.com"> 18 <a:branch>a-branch</a:branch> 19 <b:branch xmlns:b="http://yourserver.com"> 20 b-branch 21 </b:branch> 22 </a:root> 23 24 branch: 25 <branch>branch</branch> 26 27 a:branch: 28 <a:branch xmlns:a="http://myserver.com">a-branch</a:branch> 29 30 b:branch: 31 <b:branch xmlns:b="http://yourserver.com"> 32 b-branch 33 </b:branch>

?

?

2、

http://www.w3school.com.cn/xmldom/dom_errors.asp

parseError 對象的屬性

屬性描述
errorCode返回一個長整型錯誤碼。
reason返回包含錯誤原因的字符串。
line返回表示錯誤行號的長整型。
linepos返回表示錯誤的行位置的長整型。
srcText返回包含引起錯誤的行的字符串。
url返回指向被加載文檔的 URL。
filepos返回錯誤的一個長整型文件位置。

?

?

?

ZC-1:

(1)、上面的方式,xml 的 dom 都是通過"new ActiveXObject("MSXML2.DOMDocument.6.0");"得到的。

(2)、SVG內嵌html5的方式(https://msdn.microsoft.com/zh-cn/library/gg589526(v=vs.85).aspx) 的情況下,例如 如下代碼:

?

這種情況下,如何得到 xml的dom?得不到xml的dom也就不能用?selectSingleNode(...)和selectNodes(...) ...

(3)、我暫時還不知道怎么處理這種方式...暫時是使用的 js原生函數?querySelector(css選擇器) 和?querySelectorAll(css選擇器) 來完成相關選擇節點的工作的。

?

?

C

?

轉載于:https://www.cnblogs.com/codeskilla/p/5002964.html

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的xpath IE 7的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。