XML; $xml = simplexml_load_string($note); foreach($xml->body[0]->attributes() as $a => $b) { echo $a,'="',$b,'"'; }