Axes metods in Xpath



An axis represents a relationship to the context (current) node, and is used to locate nodes relative to that node on the tree.

Examples:

Navigate to https://google.com..

//textarea[@name=’q’]//..//child::textarea

//textarea[@name=’q’]//..//parent::div

//textarea[@name=’q’]//self::textarea

  • Navigate to https://techtutorialz.com..
  • Mousehover on Tutorials menu item..
  • Examples:
  • //a[@title=’AWS Tutorial’]//..//following-sibling::li[1]/a  :Find Blockchain Tutorial using “AWS Tutorial”
  • //a[@title=’ADB Tutorial’]//..//following-sibling::li[1]/a   :Find “Postman tutorial” using ADB Tutorial
  • //a[@title=’ADB Tutorial’]//..//preceding-sibling::li[1]/a   : Find “Artificial Intelligence” using “previous 1st sibling”ADB Tutorial”
  • //a[@title=’AWS Tutorial’]//..//preceding-sibling::li[1]/a : Find “Postman Tutorial”
  • //a[@title=’AWS Tutorial’]//..//preceding-sibling::li[2]/a : Find “ADB Tutorial” tutorial using “AWS Tutorial”
  • //a[@title=’AWS Tutorial’]//..//..//..//descendant::li        : Find descendent list items of “AWS Tutorial”
  • //a[@title=’ADB Tutorial’]//..//ancestor::li/ul/child::li
AxisNameResult
ancestorSelects all ancestors (parent, grandparent, etc.) of the current node
ancestor-or-selfSelects all ancestors (parent, grandparent, etc.) of the current node and the current node itself
attributeSelects all attributes of the current node
childSelects all children of the current node
descendantSelects all descendants (children, grandchildren, etc.) of the current node
descendant-or-selfSelects all descendants (children, grandchildren, etc.) of the current node and the current node itself
followingSelects everything in the document after the closing tag of the current node
following-siblingSelects all siblings after the current node
namespaceSelects all namespace nodes of the current node
parentSelects the parent of the current node
precedingSelects all nodes that appear before the current node in the document, except ancestors, attribute nodes and namespace nodes
preceding-siblingSelects all siblings before the current node
selfSelects the current node
Tags: , , ,
Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!

https://bridgejunks.com/ https://crownmakesense.com/ https://brithaniabookjudges.com/ https://hughesroyality.com/ https://rhythmholic.com/ https://bandar89.simnasfikpunhas.com/ https://www.100calshop.co.il/products/thailand/ https://myasociados.com/ https://solyser.com/ http://konfidence.cz/ https://muscadinepdx.com/ https://bandar89.parajesandinos.com.ve/ https://goremekoop.com/ https://oncoswisscenter.com/ https://www.turunclifehotel.com/bandar89/ https://www.houseofproducts.biz/ https://taimoormphotography.com/
BIJI18 BIJI18 BIJI18