fractal5 fractal5 - 1 year ago 87
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:


Answer Source

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");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download