如何通过xquery中的变量选择元素? [英] How to select an element by a variable in xquery?
本文介绍了如何通过xquery中的变量选择元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何像这样选择一个元素:
I know how to select an element like so:
$table/foo
但是,如果元素名称存储为变量,我该怎么做.例如:
However how do I do this if the element name is stored as a variable. For example:
let $x = "foo"
$table/[$x]
如果它是来自以下方面的财产,我知道该怎么做:如何通过xquery中的变量选择属性?
I know how do this if it was a property from: How to select an attribute by a variable in xquery?
推荐答案
这与问题的答案几乎相同 如何通过 xquery 中的变量选择属性? 而不是使用属性选择器 @*
,您将使用元素选择器 *
(或 element()
):
This is nearly identical to the answer for the question How to select an attribute by a variable in xquery? but instead of using the attribute selector @*
, you would use the element selector, *
(or element()
):
$table/*[local-name() = 'foo']
$table/element()[local-name() = 'foo']
这篇关于如何通过xquery中的变量选择元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文