PHP addChild() 函数
PHP 教程
· 2019-01-29 06:13:49
实例
给 body 元素和 footer 元素添加一个子元素:
<?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);
// Add a child element to the body element
$xml->body->addChild("date","2013-01-01");
// Add a child element after the last element inside note
$footer=$xml->addChild("footer","Some footer text");
echo $xml->asXML();
?>
$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);
// Add a child element to the body element
$xml->body->addChild("date","2013-01-01");
// Add a child element after the last element inside note
$footer=$xml->addChild("footer","Some footer text");
echo $xml->asXML();
?>
定义和用法
addChild() 函数给 SimpleXML 元素添加一个子元素。
语法
addChild(name,value,ns);
| 参数 | 描述 |
|---|---|
| name | 必需。规定要添加的子元素的名称。 |
| value | 可选。规定子元素的值。 |
| ns | 可选。规定子元素的命名空间。 |
技术细节
| 返回值: | 返回一个表示添加到 XML 中的子元素的 SimpleXMLElement 对象。 |
|---|---|
| PHP 版本: | 5.1.3+ |
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
An Introduction to the Analysis of Algorithms
Robert Sedgewick、Philippe Flajolet / Addison-Wesley Professional / 1995-12-10 / CAD 67.99
This book is a thorough overview of the primary techniques and models used in the mathematical analysis of algorithms. The first half of the book draws upon classical mathematical material from discre......一起来看看 《An Introduction to the Analysis of Algorithms》 这本书的介绍吧!