What is the difference between using
htmlElement.getByXPath("//section")
and
htmlElement.getByXPath(".//section")
Do they both mean that the section element is searched only inside htmlElement? (and not in the entire xml starting at dom root)
The first //section
will retrieve all <section>
elements wherever they are in your document, and independently of the context.
The second .//section
will take into account the element you are currently located in (typically in an XSL transformation), so that it will retrieve only the <section>
in the node represented by the htmlElement
variable. I don't know htmlunit, but in XPath an equivalent would be descendant::section
.