<?php
$att = 'attribueName';
// You can access an element's attribute just like this :
$attribute = $element->attributes()->$att;
// This will save the value of the attribute, and not the objet
$attribute = (string)$element->attributes()->$att;
// You also can edit it this way :
$element->attributes()->$att = 'New value of the attribute';
?>