2011-11-03 162 views
-1

我在做Dom選擇table tr td,但是這給了我所有表中的td。我怎樣才能在每一行中只選擇第二個td?大教堂的選擇 - 選擇第二個表格中的第012行

+4

總是好的,包括您所使用的代碼。 ':)' –

+0

@sameold什麼庫/工具是?這不是PHP的[native DOM](http://php.net/manual/en/book.dom.php) – Phil

回答

1

假設你正在使用DOM庫,試試這個XPath表達式

// $doc is your DOM Document 
$xpath = new DOMXpath($doc); 
$cells = $xpath->query('//table/tr/td[2]'); 
相關問題