What's the difference between //node and /descendant::node in xpath?

前端 未结 4 775
执念已碎
执念已碎 2020-12-14 15:34

I use a lot of XPath when locating elements in web pages using Selenium, and have moved away from using node1//node2 towards using node1/descendant::node2 more recently. Wha

4条回答
  •  遥遥无期
    2020-12-14 16:18

    There's a difference in the context group. //para[1] is short for /descendant-or-self::node()/child::para[1], which returns every para that is the first child of its parent. /descendant::para[1] returns only the first para in the entire subtree.

提交回复
热议问题