0

I have a HTML thus like:

<table> <tr> <th>Name</th> <th>Email</th> <th>Age</th> </tr> <tr> <td>Joe Bloggs</td> <td>[email protected]</td> <td>40</td> </tr> <tr> <td>John Doe</td> <td>[email protected]</td> <td>40</td> </tr> </table> 

Is there a way using xPath to get the first 2 columns, i.e the Name and Email fields?

I can get the table data using $data = $xpath->query( '//table'); just unsure how to get only the first 2 columns.

Many thanks

1 Answer 1

3

Get the first two td's:

//table/tr/td[position() <= 2] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.