Recall & Review
beginner
What is the purpose of the
parent axis in XPath?The
parent axis selects the parent node of the current node in the XML or HTML document tree.Click to reveal answer
beginner
How does the
child axis work in XPath?The
child axis selects all child nodes of the current node. It is often used to find direct descendants.Click to reveal answer
intermediate
Explain the
following-sibling axis in XPath.The
following-sibling axis selects all sibling nodes that come after the current node on the same level in the document tree.Click to reveal answer
intermediate
Write an XPath expression to select the parent of a node with id 'item'.
XPath:
//*[@id='item']/parent::* selects the parent node of the element with id 'item'.Click to reveal answer
intermediate
What is the difference between
child:: and // in XPath?child:: selects only direct children of the current node, while // selects nodes at any depth (descendants) from the current node.Click to reveal answer
Which XPath axis selects the parent of the current node?
✗ Incorrect
The
parent axis selects the immediate parent node of the current node.What does the XPath
child::div select?✗ Incorrect
child::div selects div elements that are direct children of the current node.Which XPath axis would you use to select siblings after the current node?
✗ Incorrect
The
following-sibling axis selects siblings that come after the current node.What is the result of
//*[@id='item']/parent::*?✗ Incorrect
This XPath selects the parent node of the element with id 'item'.
Which axis selects only direct children nodes?
✗ Incorrect
The
child axis selects only direct children of the current node.Describe how you would use XPath axes to navigate from a child element to its parent and then to its following sibling.
Think about moving up first, then sideways in the document tree.
You got /3 concepts.
Explain the difference between the
child and following-sibling XPath axes with examples.Consider the tree structure and node relationships.
You got /3 concepts.