Something like that:
<?php
$sxm = new SimpleXMLElement("<a name=\"kkk\" other=\"foo\"/>");
$attrs = $sxm->attributes();
var_dump(json_encode(reset($attrs)));
gives:
string (28) "{" name ":" kkk "," other ":" foo "}"
, , , $xmlObj->attributes() SimpleXMLElement, "@attributes" , (name = > ).