Dejan Panovski Dejan Panovski - 1 month ago 15
PHP Question

Simple HTML DOM - (direct) child selector

How can i get the inner text of the

a
element with text Title?

I'm trying with
$html->find('#someid p > a')
but it includes all nested descendant
a
elements.

<div id="someid">
<tr>... Same structure ...<tr>
<tr>
<td>
<p>
<a href="#">Title</a>
<br>
<span class="someClass">
<a href="#">text1</a>
<a href="#">text2</a>
<a href="#">text3</a>
<a href="#">text4</a>
</span>
</p>
<p>text5</p>
</td>
<td>text6</td>
</tr>
<tr>...<tr>
</div>

Answer

Try:

$e = $html->find(''#someid p > a', 0);
//or type first_child