Get entire HTML list item using Simple HTML Dom

I am currently working on a project that requires me to parse some data from an alternative website and I am having some problems (note that I am very new to PHP ).

Here is the code I am using below + the content it returns.

$dl = $html2->find('ol.tracklist',0);
print $dl = $dl->outertext;

      

The above code returns data for what we are trying to get, but below, but extremely messy, if you'd like to see click here .

However, when I put this in foreach, it only returns one of the attributes a href

at a time.

foreach($html2->find('ol.tracklist') as $li) 
{
    $title = $li->find('a',0);
    print $title;
}

      

What can I do to make it return all items a href

from the above code example?

NOTE: I use simple_html_dom.php for this.

+3


source to share


1 answer


Based on the markup, just point directly to it, just select it and then point to its anchor:



foreach ($html2->find('ol.tracklist li') as $li) {
    $anchor = $li->find('ul li a', 0);
    echo $anchor->href; // and other attributes
}

      

+1


source







All Articles