简单教程
提交运行
代码编辑器:
<?php $note = <<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body date="2017-11-01" type="private">Don't forget me this weekend!</body> </note> XML; $xml = simplexml_load_string($note); foreach($xml->body[0]->attributes() as $a => $b) { echo $a,'="',$b,'"<br>'; }
运行结果: