欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

XmlDocument的selectSingleNode方法,總支持Xpat

系統(tǒng) 1914 0

問題
??? 今天在修改程序的一個BUG時,竟然發(fā)現(xiàn)selectSingleNode方法不支持contains Xpath函數(shù),感到很奇怪。在網(wǎng)上和MSDN也沒有發(fā)現(xiàn)官方言論表明selectSingleNode不支持contains 函數(shù)。
當時我的情景大概是這樣的:

1、Xml文檔的結(jié)構(gòu)

<? xml?version="1.0"? ?> ?
< xsf:xDocumentClass? xmlns:xsf ="http://schemas.microsoft.com/office/infopath/2003/solutionDefinition" >
< xsf:errorCondition? expressionContext ="T_SUBTITLE/ICHANNELNUM" >
??
< xsf:subExpression? > Xpath_getSigleNodeValue("T_SUBTITLE/ICHANNELNUM","../ITIMESUSAGE") < 1 </xsf:subExpression > ?
??
</ xsf:errorCondition >
-?
< xsf:errorCondition? expressionContext ="T_DESCAUTHORIZE/ITIMESUSAGE" >
??
< xsf:subExpression > Xpath_getSigleNodeValue("T_DESCAUTHORIZE/ITIMESUSAGE","../ICHANNELNUM") < 1
</xsf:subExpression > ?
??
</ xsf:errorCondition >
</ xsf:xDocumentClass >

2.我的實現(xiàn)。
??? 我希望通過代碼找到expressionContext不等于T_SUBTITLE/ICHANNELNUM,并且xsf:suExpression中包含字符串"ICHANNELNUM"的節(jié)點。我書寫了以下代碼來實現(xiàn):

// aObjView_Xsf是存儲上述Xml的文檔對象
var ?aObjView_Xsf? = new ?ActiveXObject('MSXML2.DOMDocument');
aObjView_Xsf.load(
" test.xml " );
var ?objerrorConditions? = ?aObjView_Xsf.selectSingleNode( " xsf:xDocumentClass/xsf:customValidation/xsf:errorCondition[@expressionContext!=' " + strBinding + ? " '?and?contains(xsf:subExpression,' " + fieldName + " ')] " );

?? 這時IE報出錯誤:contains是未實現(xiàn)的方法!。這下我就暈了,明明在Xpath的參考手冊,MSDN上都寫著contains是支持的方法。

原因

? 難道真的不支持?
?查閱MSDN我發(fā)現(xiàn)還有以下Xpath函數(shù):

Microsoft XML Core Services (MSXML) 4.0 - XPath Reference

String Functions

concat Returns the concatenation of the arguments.
contains Returns true if the first argument string contains the second argument string; otherwise returns false.
normalize-space Returns the argument string with the white space stripped.
starts-with Returns true if the first argument string starts with the second argument string; otherwise returns false.
string Converts an object to a string.
string-length Returns the number of characters in the string.
substring Returns the substring of the first argument starting at the position specified in the second argument and the length specified in the third argument.
substring-after Returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string.
substring-before Returns the substring of the first argument string that precedes the first occurrence of the second argument string in the first argument string.
translate Returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string.

?? 難道就只有contains不支持嗎?其他函數(shù)呢?為了證實我的想法,我嘗試了上述所有函數(shù),IE都報出同樣的錯誤,原來都不支持!

原來只有4.0版本的支持
??? 我發(fā)現(xiàn)這些Xpath函數(shù)的說明在MSXML 4.0 SDK下,難道只有4.0版本支持?于是我把代碼進行了修改:

// aObjView_Xsf是存儲上述Xml的文檔對象
var ?aObjView_Xsf? = new ?ActiveXObject('Msxml2.DOMDocument. 4.0 ');
aObjView_Xsf.load(
" test.xml " );
var ?objerrorConditions? = ?aObjView_Xsf.selectSingleNode( " xsf:xDocumentClass/xsf:customValidation/xsf:errorCondition[@expressionContext!=' " + strBinding + ? " '?and?contains(xsf:subExpression,' " + fieldName + " ')] " );

????? 運行程序,竟然不再拋出contains函數(shù)不支持的錯誤了,但是出現(xiàn)另外一個錯誤,xsf是未定義的前綴。對,應(yīng)該是沒有聲明名稱空間。我對代碼再次進行了修改:

var ?aObjView_Xsf? = new ?ActiveXObject('Msxml2.DOMDocument. 4.0 ');
aObjView_Xsf.load(
" test.xml " );
aObjView_Xsf.setProperty(
" SelectionNamespaces " , " xmlns:xsf='http://schemas.microsoft.com/office/infopath/2003/solutionDefinition' " );
var ?objerrorConditions? = ?aObjView_Xsf.selectSingleNode( " xsf:xDocumentClass/xsf:customValidation/xsf:errorCondition[@expressionContext!=' " + strBinding + ? " '?and?contains(xsf:subExpression,' " + fieldName + " ')] " );

??? 運行程序,測試通過!于是我下了這樣一個結(jié)論:只有Msxml2.DOMDocument.4.0以上版本才支持這些Xpath函數(shù)。但是這個結(jié)論對嗎?我自己也不敢確定。

不只Msxml2.DOMDocument 4.0以上版本支持contains等Xpath函數(shù)

???? 我進一步的查找了一些資料,都沒有信息表明Msxml2.DOMDocument 2.0不支持這些Xpath函數(shù)。到底Msxml2.DOMDocument 2.0、Msxml2.DOMDocument 3.0為什么支持類似等于、不等于、大于這樣的操作符,而無法識別contains這樣的函數(shù)呢?直到我發(fā)現(xiàn)了這個方法:setProperty("SelectionLanguage", "XPath")。這時我恍然大悟,原來4.0以下版本的Msxml2.DOMDocument默認用類似正則匹配的方法來進行節(jié)點選取的,而4.0及以上版本默認采用Xpath作為默認的選擇語言。
??? 我采用Msxml2.DOMDocument 2.0,將代碼做以下修改也是可以正常運行的:

// aObjView_Xsf是存儲上述Xml的文檔對象
var ?aObjView_Xsf? = new ?ActiveXObject('MSXML2.DOMDocument');
aObjView_Xsf.setProperty(
" SelectionLanguage " ,? " XPath " );
aObjView_Xsf.setProperty(
" SelectionNamespaces " , " xmlns:xsf='http://schemas.microsoft.com/office/infopath/2003/solutionDefinition' " );
aObjView_Xsf.load(
" test.xml " );
var ?objerrorConditions? = ?aObjView_Xsf.selectSingleNode( " xsf:xDocumentClass/xsf:customValidation/xsf:errorCondition[@expressionContext!=' " + strBinding + ? " '?and?contains(xsf:subExpression,' " + fieldName + " ')] " );




?

XmlDocument的selectSingleNode方法,總支持Xpath函數(shù)嗎?


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 欧美精品一区二区三区在线 | 九九精品视频在线 | 免费午夜电影 | 黑人狂躁日本妞无码A片 | 亚洲天堂网在线观看 | 一级黄色免费毛片 | 欧美不卡视频一区发布 | 天天爽夜夜爽人人爽 | 亚洲天堂日本 | 色综合久久精品中文字幕首页 | 在线视频成人 | 欧美成年性h版影视中文字幕 | 日韩欧美一区二区视频 | 日韩精品视频一区二区三区 | 精品久久综合一区二区 | 欧美电影网 在线电影 | 精品国产一区二区三区久久影院 | 国产电影一区二区 | 色婷婷久久综合中文久久一本 | 久久精品伊人网 | 一级毛片a级| 中文字幕亚洲图片 | 免费啪视频在线观看免费的 | 欧美成人生活片 | 欧美视频在线观看 | 熟女毛片 | 一区二区三区四区国产精品视频 | 成人免费视频网址 | 精产国产伦理一二三区 | 一级毛片网 | 欧美日韩中文在线 | 欧美在线播放一区 | 国产精品久久久久久久久久免费 | 日韩在线第一 | 午夜欧美性欧美 | 中文字幕日韩欧美一区二区三区 | 起视碰碰97摸摸碰碰视频 | 日本高清视频www夜色资源网 | 国产色综合一区二区三区 | 男女xx| 99热热99|