tags:

views:

140

answers:

1

I want to retrieve the xpath of an attribute (example "brand" of a product from a retailer website).

One way of doing it is using addons like xpather or xpath checker to firefox, opening up the website using firefox and right clicking the desired attrbute I am interested in. This is ok. But I want to capture this information for many attributes and right clicking each and every attribute maybe time consuming. Also, the other problem I have is that attributes I maybe interested in will be there for one product. The other attributes maybe for some other product. So, I will have to go that product & then do it manually again.

Is there an automated or programatic way of retrieving the xpath of the desired attributes from a website rather than having to do this manually?

+1  A: 

You must notice that not all websites use valid XML that you can use xpath on...

That said, you should check out some HTML parsers that will allow you to use xpath on HTML even if it is not a valid XML.

Since you did not specify the technology you are working with - I'll suggest the .NET HTML Agility Pack, if you need others, search for questions dealing with this here on SO.

Dror