我有一個字符串,我想用它作爲xpath中的選擇器來選擇名稱作爲字符串值的節點。xpath中的字符串
declare variable $get_count := <count><comedy>1</comedy></count>;
(: $string = "comedy" :)
let $value = $get_count/$string (: but this doesn't return anything)
我該怎麼做?
我有一個字符串,我想用它作爲xpath中的選擇器來選擇名稱作爲字符串值的節點。xpath中的字符串
declare variable $get_count := <count><comedy>1</comedy></count>;
(: $string = "comedy" :)
let $value = $get_count/$string (: but this doesn't return anything)
我該怎麼做?
let $value = $get_count/$string (: but this doesn't return anything)
使用:
declare variable $get_count := <count><comedy>1</comedy></count>;
declare variable $string := "comedy";
let $value := $get_count/*[name()=$string]
return
$value
當這對任何XML文檔(未使用),則希望,正確的結果產生應用:
<comedy>1</comedy>
好問題, +1。看到我的答案是一個簡單而直接的解決方:) – 2010-12-14 19:13:15