I write the following xpath to extract name and price from table.
/html/body/div[2]/div[7]/div[3]/table[1]/tbody/tr
but it can't extract
I write the following xpath to extract name and price from table.
/html/body/div[2]/div[7]/div[3]/table[1]/tbody/tr
but it can't extract
There is no tbody
element in the source HTML of that page (try this yourself by opening the source document and searching for "tbody").
Unfortunately, browsers (including browser plugins, n.b.) tend to add tbody
elements to the DOM representations even if they are not actually there.
I have no idea what you are trying to find on that page (you did not explain it clearly enough), but if you were searching for
//table/tbody/tr
and that did not return anything, the first thing you should try instead is
//table//tr
and see if it makes a difference. If it doesn't, the next thing to look out for is namespaces. The document that serves as your input (allegedly) is XHTML, which requires elements to be in a namespace:
<html lang="fa" xml:lang="fa" xmlns="http://www.w3.org/1999/xhtml">
Depending on the XPath engine you are using (again, we don't know), you need to cleanly register namespaces with prefixes, and prefix element names.