Skip to content
Advertisement

Is there a way to convert an element link to XPath

I have written a Jsoup class file to scrape a page and grab the hrefs for every element on the page. What I would like to do from there is to extract the Xpath for each of the elements from their hrefs.

Is there a way to do this in JSoup? If not is what is the best way to do this in Java (and are there any resources on this)?

Update

I want to clarify my question.

I want to scan a page for all the href identifiers and grab the links (that part is done). For my script, I need to get the xpath of all the elements I have identified and scraped from the (scanned) page.

The problem is that I assumed I could easily translate the href links to Xpath.

Advertisement

Answer

The comment from @Rishal dev Singh ended up being the right answer. Check his link here: http://stackoverflow.com/questions/7085539/does-jsoup-support-xpath

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement