This project has moved and is read-only. For the latest updates, please go here.

How to get xpath from browser

Aug 27, 2009 at 3:00 AM

I need xpath grabber from a a web page in IE or FireFox.

There are a plugin in FireFox that does exactly this. you highlight the text taht you want, and view the xpath in the xpather.

the problem is that this is not accurate, and htmlagility pack doesn't understand the xpath. I removed tbody anf form and still it is not perfect.

is there htmlagility add on for firefox or explorer or whatever?

it is just too difucult correct the xpaths of the xpather , i find it very inconvinence.


Aug 29, 2009 at 4:18 PM


FireFox seem to always add "tbody" elements even when the actual HTML doesn't have any tbody elements. This is then shown in the Addon. I have no knowledge about FF addons so I might be wrong.

The original HAP (HtmlAgilityPack) has some ... issues with form, option, and script-tags. There are several patches and code fixes on Issue Tracker or Discussion. I have myself altered the original HAP to make it work in my use, mostly using the code supplied on this website.

I too use the FireFox addon, but with the use of HAP itself, I created a WinForms app with a TreeView, the treeview lists nodes as HAP sees them, and I can click each node and the respective XPath is availiable for me. This tool also helps me spot bugs HAP has. I have 2 versions, one using the original HAP release and one using the HAP I have modified.

One issue is that you should know how HAP works, without this knowledge you can test yourself to pieces and still don't get anything.

It's kind of silly when HAP "dies" after a <script>-tag, which usually is at the top of the page, and your XPath is fine, the HTML is fine, and you get no errors ... the pain!

I plan to publish a patch for HAP combining all existing patches and fixes. But since my focus is on the project that is using HAP and not HAP itself, my dedication for this goal is limited. Hopefully DarthObiwan and I can join forces and try get something out.

Sep 1, 2009 at 5:47 PM

can you please compile the winform and post it here for download? of ther released version of course.

I guess patches can wait till next version.


Oct 4, 2010 at 4:39 PM

yes please!!!