sameold
sameold

Reputation: 19242

Dom selection - selecting the second td in table row

I'm doing Dom selection with table tr td but this gives me all td in the table. How can I choose only the second td in every row?

Upvotes: 0

Views: 449

Answers (2)

Phil
Phil

Reputation: 164811

Assuming you're using the DOM library, try this XPath expression

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

Upvotes: 1

olivieradam666
olivieradam666

Reputation: 4660

You can try

table tr td:nth-child(2)

Upvotes: 1

Related Questions