java - Highlight nodes covered by XPath -
i want highlight nodes covered given xpath in html page source.
i looked in htmlunit, not find thing in api.
at present, thinking of doing following way:
- get xpath , page-source.
- break xpath smaller chunks , store them in xpath_chunk[].
- apply chunk xpath_chunk[] starting 0.
- update css property of each node found each chunk(any change distinguishes text).
- now add next chunk , concate current.
- go step 3.
in way, visit nodes covered xpath. more changes can remove elements unnecessarily highlighted.
this complicated. there way ?
i made rudimentary implementation using javafx's webengine + webview. register dom listener nodes of loaded website's document, can listen clicks on nodes. when clicking, change style of node , add css. webview reflect changes , render page correctly.
the document webengine returns can accessed using xpath (it's w3d document), can traverse , modify nodes encounter (or use node furthest down, travel upwards using getparent(), , modify each parent well).
Comments
Post a Comment