简单教程
提交运行
代码编辑器:
<?php $note = <<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> XML; $xml = new SimpleXMLElement($note); $xml->addAttribute("type","private"); $xml->body->addAttribute("date","2013-01-01"); echo $xml->asXML();
运行结果: