How does dot(.) in xpath to take multiple form in identifying an element and matching a text

前端 未结 2 1940
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 03:00

I have the below dom structure:

Associated Elements&a
2条回答
  •  抹茶落季
    2020-12-22 03:14

    The text() in contains(text(),'Associated Elements') is a selector that matches all of the text nodes that are children of the context node - it returns a node-set. That node-set is converted to string and passed to the contains() function.

    text() isn't a function but a node test. It is used to select all text-node children of the context node. So, if the context node is an element named x, then text() selects all text-node children of x.

    When you use contains(., 'Associated Elements') only an individual text node is passed to the function and it is able to uniquely match the text.

    Note: copied and edited from this and this post.

提交回复

热议问题