vendredi 6 juin 2014

How to select an ancestor node with php xpath


Vote count:

0




I have the following html:



<tbody>
<tr>
<td height="1" bgcolor="#B0B0D4">
<img width="200" height="1" alt="mytext" src="....."/>
</td>
</tr>


I can select for the img element with:



@$dom->loadHTML($html);
$xpath = new DOMXPath($dom); HTML
$elt = $xpath->evaluate("//img[@alt='mytext']") ;


How can I select for the parent with php's xpath?


I've tried:



$elt = $xpath->evaluate("//tr//img[@alt='mytext']") ;


asked 53 secs ago

user61629

1,248





Aucun commentaire:

Enregistrer un commentaire