I think this gets the first element called
$gallery = $objDOM->getElementsByTagName(\'gallery\')->item(0);
This is only possible with DOMXPath, e.g.
$xp = new DOMXPath($yourDOMDocument);
$nodes = $xp->query('//gallery[@name="Third"]');
or by iterating over the node list after the call to getElementsByTagName
with
foreach ($objDOM->getElementsByTagName('gallery') as $gallery) {
if($gallery->getAttribute('name') === 'Third') {
// do something
}
}