2010-11-20 101 views
0
<model>BMW, Merc, sakoda</model> 

我需要檢查BMw是否是模型。查詢中的字符串匹配

It is throwing me an error. Could you please tell me how to do it. 
+0

我不知道xquery,但包含APPEARS將缺少最後一個]此外,張貼實際的錯誤消息將幫助知道xquery的人識別問題... – Sparky 2010-11-20 12:47:57

+0

嘗試在寶馬周圍放置單引號或雙引號 – CarneyCode 2010-11-20 12:56:20

+0

不,它不起作用 – user507087 2010-11-20 13:01:32

回答

0

使用

xs:boolean(doc("car.xml")/car/model[contains(.,'BMW')]) 

這個計算結果爲true()false()取決於是否有一個元素:

doc("car.xml")/car/model

包含字符串 '寶馬'

+0

'contains()'函數調用中存在拼寫錯誤。 – 2010-11-20 22:25:23

+0

@Alejandro:謝謝你注意到這一點。固定。 – 2010-11-20 23:41:44