DOMDocument in php
<div id="showContent"> <table> <tr> <td> Crap </td> </tr><tr> <td width="172" valign="top"><a href="link"><img height="91" border="0" width="172" class="" src="img"></a></td> <td width="10"> </td> <td valign="top"><table cellspacing="0" cellpadding="0" border="0"> <tbody><tr> <td height="30"><a class="px11" href="link">title</a><a><br> <span class="px10"></span> </a></td> </tr> <tr> <td><img height="1" width="580" src="crap"></td> </tr> <tr> <td align="right"> <a href="link"><img height="16" border="0" width="65" src="/buy"></a> </td> </tr> <tr> <td valign="top" class="px10"> <p style="width: 500px;">description.</p> </td> </tr> </tbody></table></td> </tr> <tr> <td>Crap </td> </tr> <tr> <td> Crap </td> </tr> </table> </div>
tr
$dom = new DOMDocument();@$dom->loadHTML($html);$xpath = new DOMXPath($dom);$tags = $xpath->query('.//div[@id="showContent"]');foreach ($tags as $tag) { $string=""; $string=trim($tag->nodeValue); if(strlen($string)>3) { echo $string; echo '<br>'; }}
CrapCrapTitleDescription
<tr> <td>Crap</td></tr><tr> <a href="link">title</a></tr>