The DOMDocument::documentElement is the root element node. In your XML, this would be the video element node. It is not a node list, but the actual node, so foreach will not work.
Just remove the outer foreach
$dom = new DOMDocument();
$dom->load('new_result.xml');
$video = $dom->documentElement;
foreach($video->getElementsByTagName('youtube') as $youtube) {
echo ' video url ' . $youtube->nodeValue;
}
If you XML gets more complex you can use Xpath expressions:
$dom = new DOMDocument();
$dom->load('new_result.xml');
$xpath = new DOMXpath($dom);
foreach($xpath->evaluate('/video/youtube') as $youtube) {
echo ' video url ' . $youtube->nodeValue;
}
Most Xpath expression will return node lists, but they can return scalar values. With that you can eliminate the second loop, too:
$dom = new DOMDocument();
$dom->load('new_result.xml');
$xpath = new DOMXpath($dom);
echo ' video url ' . $xpath->evaluate('string(/video/youtube[1])');