I need the same functionality. The idea I had was to look at the location of the tag relative to a fixed element, such as the BODY tag, and use an XPATH expression as a unique identifier. For example, if there is HTML, for example
<BODY><TABLE><TD>
... etc., the unique identifier for TD can be / Body / Table / 1 ... and so on. But this suggests that the next time the page is displayed, there will be no more nodes that were before. A slight improvement may be to use the "ID" tags in the path when they are generated, rather than using them where not. For example, suppose the page:
<BODY> <DIV id="test"> <TABLE id="testtable"> <TR><TD></TD></TR> .....
The unique identifier for the TD tag can be / Body / Div @ test / Table @ testtable / TD @ 0, etc.
source share