Php Html Domdocument

0

Posted by admin | Posted in Uncategorized | Posted on 06-03-2009

Tags: , , , ,

i need hеlр wіth php DOM ? need a lіttlе change іn mу code?

i want to echo all the linkname and their urls
i got the code below for the url ,just dont know how to get the link name…?

$dom = new DOMDocument();
@$dom->loadHTML($content);

$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate(“/html/body//a”);

fοr ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute(‘href’);
echo “
Link stored: $url”;

//// i tried this//// $linkname=$href->getAttribute(‘name’);
///echo”$linkname
“;
}

Try this one:

echo $href->getAttribute(‘href’);
echo $href->nodeValue;

Regards

http://www.rapidsharehub.com/

Ajax Dom [Document Object Model]


Write a comment