Skip to content

关于选择器查询结果数量的疑问 #569

Closed Answered by lisonge
adproqwq asked this question in Q&A
Discussion options

You must be logged in to vote

只从查询结果数量上看,数量为 1 是正确的

因为选择目标始终是 [text*="广告"][visibleToUser=true]

选择器是原理是遍历所有节点,然后检测这个节点是否满足你给出的 此节点作为起点的路径约束

如果满足就返回路径上的节点作为一个数组,@ 只是决定选取这个数组的索引

尽管可能有多条子约束符合条件,但是只会选取最先得到的一个约束

比如 @* > [_id=20]@* >n [_id=20] 没有区别

因为 @* >n [_id=20] 在 n=1 时是 @* > [_id=20] 此时已经找到符合条件的约束,自然不会再找 n=2,3,4... 之后的约束路径

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@adproqwq
Comment options

Answer selected by adproqwq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants