Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过xpath选择除少数节点外的所有节点_Xpath_Orbeon_Xforms - Fatal编程技术网

通过xpath选择除少数节点外的所有节点

通过xpath选择除少数节点外的所有节点,xpath,orbeon,xforms,Xpath,Orbeon,Xforms,只是一点点帮助。请让我知道正确的xpath表达式 我有这样的xml文档 <parent> <child id='1' show='true' /> <child id='2' show='true' /> <child id='3' show='true' /> <child id='

只是一点点帮助。请让我知道正确的xpath表达式

我有这样的xml文档

<parent>
                    <child id='1' show='true' />
                    <child id='2' show='true' />
                    <child id='3' show='true' />
                    <child id='4' show='true' />
                    <child id='5' show='true' />
                    <child id='6' show='true' />
                </parent>


我想选择除第二个和第五个孩子以外的所有
show
属性,以便我可以将它们的值设置为
false

您可以在XPath表达式中使用布尔

/parent/child[@id != '2' and @id != '5']
如果确实需要第二个和第五个元素,可以使用
position()
函数:

/parent/child[position() != 2 and position() != 5]
使用

/*/*[not(position() = 2 or position() = 5)]/@show

这将选择xml文档顶部元素的任何子元素的任何
show
属性,该子元素不是其父元素的第二个或第五个子元素。