A bit, but I'm new to xPath, so not as much as I'd hoped 8)
Poking around has got me here:
String data = book.getContents().get(chapterID-1).toString();
XPathFactory factory = XPathFactory.newInstance();
XPath xPath = factory.newXPath();
NodeList headings = (NodeList) xPath.evaluate("/html/body/*[self::h2]/text()", data, XPathConstants.NODESET);
But it says I have an unknown error in xpath. What am I missing? And is that the expression I'm looking for?