主页
PHP
PHP addChild() 函数
demo_func_simplexml_addchild
运行 ❯
×
更改方向
保存代码
更改主题
<?php $note=<<
Tove
Jani
Reminder
Do not forget me this weekend! XML; $xml=new SimpleXMLElement($note); // Add a child element to the body element $xml->body->addChild("date","2014-01-01"); // Add a child element after the last element inside note $footer=$xml->addChild("footer","Some footer text"); echo $xml->asXML(); ?>
Select View Source to see the added "date" and "footer" elements.