python--finding elements by XPath relative node position (cont.)

Source: Internet
Author: User
Tags xpath
The method previously written about the relative parent element and the next sibling element.

This time, add all the methods for finding elements in the XPath relative node location. Example will not give up, you can go to practice.

XPath relative node Lookup method:

1. XPath ('./ancestor::* ')
Finds all ancestors of the current node, that is, parent node or grandparent node

2. XPath ('./ancestor-or-self::* ')
Finds all ancestor nodes of the current node and itself

3. XPath ('./attribute::* ')
Gets all the properties of the current node

4. XPath ('./child::* ')
Finds all child nodes of the current node

5. XPath ('./descendant::* ')
Gets all descendant nodes of the current node, that is, child nodes, grandchild nodes

6. XPath ('./following::* ')
Gets all nodes after the current node end tag

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 current node start label

10. XPath ('./preceding-sibing::* ')
Gets the previous sibling node of the current node

11. XPath ('./self::* ')
Select the current node

That's probably all, and these methods are very useful, especially if some elements cannot be found by their properties, they need to be located by relative nodes.

python--finding elements by XPath relative node position (cont.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.