fractal5 fractal5 - 6 months ago 24
HTML Question

How to get all childs of a node using php xpath?

In the code below:

<tr class='even'>
<th>header 1</th>
<tr class='even'>
<th>header 2</th>

When I run,

It only shows me the contents of the
tags. Shouldn't I be getting the contents of the
as well i.e. everything inside the

If not how can I get the td without having to write separate ones like this:



You can use * selector that select any tag.


The above code select every child of tr.even. Also you can use | (OR) operator like bottom code.

$xpath->query("//tr[@class='even']/td | //tr[@class='even']/th");