使用PHP获取多个XML属性

I have this XML:

<response>
<method>keyword.domain.seo</method>
<answer>
<result kw="moos entfernen" position="74" competition="39" traffic="30" url="https://www.gartenbau.org/moos-entfernen-201816621"/>
<result kw="moosentfernung" position="93" competition="52" traffic="20" url="https://www.gartenbau.org/moos-entfernen-201816621"/>
</answer>
<date>2018-08-27T15:13:04+02:00</date>
<credits used="2"/>
</response>  

I would like to parse the attributes inside both tags <result>. I used this code but it only fetches the attributed inside the "first" tag <result>.

 $xml=simplexml_load_string($content) or die("Error: Cannot create object");
          foreach($xml->answer->result as $result){
                foreach($result->attributes() as $a => $b) {
                    echo $a,'="',$b,"\"
";
                }
          }