views:

160

answers:

1

Hi everyone, 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">Goodbye</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?

+1  A: 

Try using this selector.

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

Check out the documentation for more examples.

The Pixel Developer
Thank you, that did it, you've been a great help.
Joe