0

I am running into a weird problem with accessing nodes in my XML file.

If I do (in my XQuery file) :

return <result>$myfile/option[2]</result>

It works fine, however, if I try :

return <result>$myfile/option[$myfile/data(@index)]</result>

It doesn't work. The value of $myfile/data(@index) is 2.

Any insights would be greatly appreciated.

4

1 に答える 1

0

の値$myfile/data(@index)は 2 です

数字の2ではなく文字列「2」だと思います。キャストしてみてください

return <result>$myfile/option[xs:integer($myfile/data(@index))]</result>
于 2013-03-28T15:42:27.333 に答える