欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 亚洲一区二区视频在线观看 | 午夜欧美 | 天天躁日日躁狠狠躁中文字幕 | 国产精品色 | 日韩欧美一区二区三区久久 | 欧美在线一级片 | 国产精品久久久久无码av | 天天色综合影视 | 最新av在线网址 | 精品久久综合一区二区 | 欧美乱码伦视频免费 | 日韩a电影 | 大色综合色综合资源站 | 91精品国产91久久久久久最新 | 激情小说激情图片激情电影 | 国产美女亚洲精品久久久综合 | 青青热在线观看视频精品 | 国产精品成人在线观看 | 亚洲欧美一区二区三区综合 | 黄片毛片一级 | 亚洲视频免费观看 | 亚洲欧美日本人成在线观看 | 午夜视频十八嗯嗯啊免费 | JLZZJLZZ亚洲乱熟在线播放 | 欧美国产精品一区二区 | 亚洲欧美一区二区三区综合 | 不卡一二三区 | 成人亚洲A片V一区二区三区婷婷 | 91在线入口 | 狠狠撸电影院 | 99久久亚洲精品日本无码 | 2022国产成人福利精品视频 | 精品福利在线视频 | 国产精品视频免费观看 | 亚洲毛片网站 | 91成人免费看| 久久久影院 | 国产亚洲综合久久 | 精品在线观看国产 | 欧美激情人成日本在线视频 | a高清免费毛片久久 |