开发者

generate/get the Xpath for a selected textnode

开发者 https://www.devze.com 2022-12-24 06:24 出处:网络
Is it possible to get/generate the XPath, for a text selected in the HTML page. Say,I have opened an html file using a brow开发者_JAVA百科ser,say safari/firefox, now i select some text (using mouse),

Is it possible to get/generate the XPath, for a text selected in the HTML page. Say,I have opened an html file using a brow开发者_JAVA百科ser,say safari/firefox, now i select some text (using mouse), i want to generate/get the xpath for that. is it possible to get it programatically? how?


Some years ago I wrote the following sample and tested it to work with Mozilla and with Opera. It stores the selection in a cookie and can restore the selection from that cookie. It generates and stores an XPath expression to the startContainer and endContainer of the selected range and the numbers of the offset.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号