You can access a node child with his name this way :
<?php
$root = new SimpleXMLElement($filePath);
echo $root->nodeName->attributes;
echo $root->nodeName->subNodeName->attributes();
?>
But if you want to ADD an attribute to a children you MUST use the children() method to access and modfiy it or it will modify the parent's attributes.
<?php
$element->nodeName->addChild('subNodeName', "whatever you want");
$lastNodePos = $element->nodeName->count()-1;
$nodeChildrens = $element->nodeName->children();
$nodeChildrens[$lastNodePos]->addAttribute('attributeName', "The attribute value);
?>