开发者

Problem getting contents of class using php simple dom parser

I can't work out how to get the contents of the second span 'cantfindme' using php simple html dom parser(http://simplehtmldom.sourceforge.net/manual.htm). Using the code below I can get the contents of the first span 'dontneedme'. I cant seem to get anything from second span at all.

$html =  str_get_html('<html><body><table><tr><td class="bar">bar</td><td><div class="foo"><span class="dontneedme">Hello</span></div></td></tr><tr><td class="bar">bar</td><td><div class="foo"><span class="cantfindme">G开发者_JAVA技巧oodbye</span></div></td></tr></body></html>');
foreach($html->find('.foo', 0) as $article) 
{

    echo "++</br>";
    echo $article->plaintext;
    echo "--</br>";
}

Can anyone see where I'm going wrong?


Try using this selector.

$html->find('div.foo .cantfindme');

Check out the documentation for more examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜