$xml = simplexml_load_string($res); foreach($xml->Tag3 as $r){ foreach ($r->attributes() as $a => $b) { echo $a,'="',$b,"\"\n"; } }