Re: preg_match_all

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 29, 2008 at 8:13 PM, Eric Butera <eric.butera@xxxxxxxxx> wrote:
> Why not use DOMDocument with getElementsByTagName('href') [1]
>
> http://us2.php.net/manual/en/domdocument.getelementsbytagname.php
>

Sorry there was an error in that.  It felt wrong when I sent it so I
looked again.  Here is a snippet I'm using on a project right now, so
I know it works. ;)

$dom = DOMDocument::loadHTML($vo->htmlCopy);
foreach ($dom->getElementsByTagName('a') as $node) {
    if ($node->hasAttribute('href')) {
        $linkVO = new ...;
        $linkVO->url            = $node->getAttribute('href');
        $linkVO->name           = $node->nodeValue;

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux