views:

18

answers:

2

I need to get the data out of all of the table cells in the 4th row of the 4th table on an HTML page. After researching for a while, it seems that using DOMXPath is the best way to parse the HTML file. However, no IDs or classes are used anywhere in the file. What would be the best way to get the data out of these cells?

Thanks in advance.

A: 

You can specify an index when fetching with XPath. In your case

/html/body/table[4]/tbody/tr[4]/td

Note that an XPath index is not zero-based, but one-based.

Gordon
I had to remove the tbody node to get it to work, but this method does work. Thanks!
Matt Robertson
A: 

If you are familiar with jQuery syntax, have you looked into phpQuery?

degenerate