我试图从使用PHP简单的HTML Dom解析器的网站检索一些信息。在网站上有很多表“forumborder2”的表格,里面我想获得一些信息。在下一个例子中,我想要图像源。PHP - 简单的HTML Dom解析器
<table class="forumborder2" width=100% cellspacing=0 cellpadding=0 border=0 align=center>
<tr>
<td class="titleoverallheader2" background="modules/Forums/templates/chunkstyle/imagesnew/forumtop.jpg" style="border-top:0px; border-left:0px; border-right:0px;" width="100%" colspan=7 Align=left>
<b>Supernatural </b>(2005) - Enviada por: <b>AlJoSi</b> em 6 de Dezembro, 2011 (22:35:11)
</td>
</tr>
<tr height=25>
<td class="colour12" align=right width=100>
<b>Idioma:</b>
</td>
<td width=110 class="colour22">
<img src="modules/Requests/images/fPortugal.png" width=18 height=12 border=0 alt='' title=''>
</td>
</tr> </table>
我做了以下内容:
foreach($html->find('table[class="forumborder2"]')as $tr){
echo $tr->children(1)->children(1)->src; }
这总是给人错误:“试图获得非对象的属性”。如果我只去$tr->children(1)->children(1)
我可以得到<img src="modules/Requests/images/fPortugal.png" width=18 height=12 border=0 alt='' title=''>
为什么我不能访问src属性。
什么是“简单的HTML DOM解析器”?和**什么错误**? – Jon
@Jon,[PHP简单HTML DOM解析器](http://simplehtmldom.sourceforge.net/)。也改变了错误的帖子。 – Barata