I can\'t seem to figure this one out. I have the following XML file:
if I understand that correctly, doesn't that only test the first node?
Yes. So if you want to use DOM methods like that one, you'll have to do it in a loop. eg.:
$buildings= $xdoc->getElementsByTagName('building');
foreach ($buildings as $building)
if ($building->getAttribute('name')==$name)
return true;
return false;
With XPath you can eliminate the loop, as posted by Dimitre and sgehrig, but you'd have to be careful about what characters you allow to be injected into the XPath expression (eg. $name= '"]' will break the expression).