xml加个节点如何写

WBOY
Release: 2016-06-13 12:52:57
Original
994 people have browsed it

xml加个节点怎么写
xml 结构如下







php如下
$note  = simplexml_load_file("a.xml");
$note->appendChild(new DOMElement("time","aaa"));


------解决方案--------------------
PHP在处理XML上有很多扩展,你的代码使用了simplexml类,也使用了DOMElement类,这两个类属于不同的扩展,所以不能用在一起。

提供一个simplexml的示例
$note  = simplexml_load_file("a.xml");<br />
$note->addChild("time","aaa");<br />
file_put_contents('a.xml', $note->asXML());
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template