Q:

How to check if TAG exists inside XML with PHP?

How do i check if a TAGname exists inside an XML file.
so if i want to get 
$dom->getElementsByTagName('error')
and it doesn't exist, it prints out something like an error message.
EDIT:
I'm working from an API. So what happens is when a user enters an incorrect username, another XML files is loaded that contains the tag <error>.
However, if they enter the correct username, the XML file doesn't contain the <error> tag so I'm looking for a way to check if the error tag exists inside an XML.

A:

$dom = new DOMDocument(); 
$dom->load( 'some.xml' ); 

$errorNodes = $dom->getElementsByTagName('error'); 

if($errorNodes->length == 0)
{
  message('no error nodes'); // user defined
}

