Nikhil Sharma
Nikhil Sharma

Reputation: 19

Auto Extracting XPATH of all html elements using JAVA

Wanted to write a Java program to extract all the Xpaths of a given HTML page. For POC, using Gmail login page as an example. In the example. i click on the google logo and it gives me an Xpath to it. I should be able to extract all the xpaths of all the elements through a JAVA program and be able to save in a json format. Ex: {"logo": "html/body/div[1]/div[1]/div/div", ....., .....}. Please suggest if there are any libraries available to carryout this task?

Image link to better explain: http://i65.tinypic.com/347zcj6.jpg "googleXpathExample"

Upvotes: 0

Views: 2920

Answers (1)

1 parse the XHTML (if it is well-formed XML), with DOM, or use JSoup

2 node => Xpath: see this

Generate/get xpath from XML node java

Upvotes: 0

Related Questions