Just trying to add some clarification: this function will return boolean "false" when there is not a $name attribute :)
Cheers, Alex(PHP 5, PHP 7, PHP 8)
DOMElement::getAttributeNode — 属性ノードを返す
   現在の要素の、qualifiedName
   という名前の属性ノードを返します。
  
qualifiedName属性の名前。
   属性ノードを返します。
   XML の名前空間宣言
   (xmlns や xmlns:* 属性) については、
   DOMAttr オブジェクトではなく、
   DOMNameSpaceNode が返されることに注意してください。
  
