Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Python-- finds elements through xpath relative node position (continued)

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

I have previously written methods relative to the parent element and the next sibling element.

This time supplement all the methods that xpath uses to find elements relative to the position of the node. Instead of citing examples, you can go to practice.

Xpath relative node search method:

1. Xpath ('. / ancestor::*')

Find all ancestor nodes of the current node, that is, parent or grandfather nodes

2. Xpath (. / ancestor-or-self::*')

Find all ancestor nodes of the current node as well as itself

3. Xpath (. / attribute::*')

Get all the attributes of the current node

4. Xpath ('. / child::*')

Find all children of the current node

5. Xpath ('. / descendant::*')

Get all descendant nodes of the current node, that is, child node and grandnode

6. Xpath ('. / following::*')

Gets all nodes after the end tag of the current node

7. Xpath ('. / following-sibing::*')

Gets the next sibling node of the current node

8. Xpath ('. / parent::*')

Gets the parent node of the current node

9. Xpath (. / preceding::*')

Gets all nodes before the start label of the current node

10. Xpath ('. / preceding-sibing::*')

Gets the last sibling node of the current node

11. Xpath ('. / self::*')

Select the current node

That's about it, and these methods are very useful, especially if some elements cannot be found through their own attributes, they need to be found relative to the location of the node.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report