XPath selects nodes in an XML tree. Paths use / for root-down, // for anywhere, . current, .. parent.
/library/book— books under library//title— all title elements/library/book[1]— first book (1-based in XPath 1.0)
Challenge
Select titles
- Keep a small
<library>with three<book><title>nodes. - In notes, write the XPath
//titleand what it returns.
Done when: document is well-formed and you can explain the node list mentally.
Interview prep
- What is XPath?
A path language for selecting nodes in an XML tree — used in XSLT, XPointer, and many test tools.