首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

xml加个节点如何写

2013-03-06 
xml加个节点怎么写xml 结构如下?xml version1.0 encodingutf-8?note/notephp如下$note simpl

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

<?xml version="1.0" encoding="utf-8"?>
<note>
</note>



php如下
$note  = simplexml_load_file("a.xml");
$note->appendChild(new DOMElement("time","aaa"));
[解决办法]
PHP在处理XML上有很多扩展,你的代码使用了simplexml类,也使用了DOMElement类,这两个类属于不同的扩展,所以不能用在一起。

提供一个simplexml的示例

$note  = simplexml_load_file("a.xml");
$note->addChild("time","aaa");
file_put_contents('a.xml', $note->asXML());

热点排行