here is two line code may it help some one
$html = file_get_html($link);
foreach($html->find("a") as $key=>$val)
{
echo $val->src;
echo '\n';
}
Use DOMNode::$nodeValue:
echo $url->nodeValue;
foreach ($urls as $url) {
$attributes = $url->attributes;
echo "<br>$url->nodeValue is $attributes->href";
}
The text "Test" is actually a DOM Text node so you can fetch the content by going through the children nodes of $url.
You can check this post for solution: How to get innerHTML of DOMNode?