title: How to tell apart SimpleXML objects representing element and attribute?
body: <p>I need to print <em>arbitrary</em> SimpleXML objects in a specific manner, with special handling of attribute nodes.</p>
  
  <p>The problem is that SimpleXML elements and attributes seem to use exactly the same class, attribute node even pretends to support <code>attributes()</code> method, and SimpleXML hides its internals, so there doesn't seem to be any way to tell type of node (short of generating XML and reparsing it).</p>
  
  <p>Both give <em>identical</em> result:</p>
  
  <pre><code>$element = new SimpleXMLElement('&lt;foo&gt;test&lt;/foo&gt;');
  echo $element;
  print_r($element);
  
  $element = new SimpleXMLElement('&lt;foo attr="test" /&gt;');
  echo $element['attr'];
  print_r($element['attr']);
  </code></pre>
  
  <p>Is there a hidden property/method that allows identifying type of node in SimpleXML? Equivalent of DOM's <code>$node-&gt;nodeType</code> or <code>$node instanceof DOMAttr</code>? (I can't use DOM instead, support for SimpleXML is core requirement).</p>