On 6 May 2010 10:55, Peter Lind <peter.e.l...@gmail.com> wrote:

>
>
> You could parse the document with the DOM classes. Load as a
> DOMDocument, then grab what's needed with the relevant methods (you
> can use xpath to single out your divs with the right classes).
> http://dk2.php.net/domdocument
>
>
>
Xpath is indeed the way to go. For example...

/* .. your code.. */
$data = file_get_contents($url);
$inDoc = new DOMDocument();$inDoc->preserveWhiteSpace =
false;@$inDoc->loadHTML($data);
$xpath = new DOMXPath($inDoc);$xlinks =
$xpath->query('//d...@class="b"]/a');for ($a = 0, $z =
$xlinks->length; $a < $z; ++$a) {
        $link = $xlinks->item($a);
        $href = $xlink->attributes->getNamedItem('href')->value;

}

To be safe, you should use an ID instead of a class, though.

Michiel

Reply via email to