Try this code
$doc = new DOMDocument();
$doc->loadXML('abbar');
$foos = $doc->getElementsByTagName('foo');
foreach($foos as $v){
echo $v->firstChild->wholeText.'
';
}
The firstChild property of DOMNode returns a DOMText object as there is a "text node" before in first