Jump to content

php simple dom find all children


ludo1960

Recommended Posts

Hi guys,

I am usingĀ this dom parser, and its pretty easy to find all links on a page then following the links to sub pages, but how do I know when to stop, i.e.when the page has no more children? I came across this script for dealing with child pages, but needless to say it outputs nothing:

$links = $html->find('div.layout');

    foreach ($links as $link) {
        foreach ($link->children() as $children) {
            if ($children->tag == 'a') {
                $output [] = $children->plaintext; //or whatever you want
            }
        }
    } 

How do I test for a link that has no more children?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.