Object of class DOMElement could not be converted to string
$link
is an object which can not be converted to string (some objects can).
To see which object it is, use var_dump($link);
. I assume it's a DOMElement
Docs, see the link for all properties and methods it has to offer, e.g.
echo $link->tagName;
or
echo $link->textContent;