See the question and my original answer on StackOverflow

Most of the time, you cannot take an XPATH given by a browser debug tool (Chrome, FF, etc...) and use it as is in a tool such as Html Agility Pack.

The reason is a browser gives you the XPATH of an in-memory element, while Html Agility Pack will see the XPATH from the source HTML stream.

The most frequent cases of discrepancy between the two XPATHs expressions is element that are added by browsers; for example TBODY. TBODY is rarely defined in HTML files, but is always added by browsers. So you could try this:


but I certainly don't guarantee it to work. The best is to have an human look at the source HTML and come up with a good discriminant (and future tolerant) XPATH expression, something like this for example:


Meaning "get all 'myElement' tags which have a 'class' attribute with 'someclass' as the value.

We could help more with the HTML source and what element you want to get at.

EDIT: to get the price displayed in blue in the url you gave, if you take a quick look at it, you will see the discriminant is precisely the color, so you can imagine an XPATH like this:


Wich means:

  1. From the root (/)
  2. Get any TD element recursively in the document (double / means recursively) with a BGCOLOR attribute with value equals to '#D1DFFC'
  3. From that TD, look recursively and search for a B element.

So a C# code like this:

        HtmlDocument doc = new HtmlDocument();

        foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//td[@bgcolor='#D1DFFC']//b"))

will display