PHP操作XML问题
我用php生成xml如下
- PHP code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$xml = '<?xml version="1.0" encoding="utf-8"?>'."\r\n";$xml .= ''."\r\n";$xml .= "\t".''.www.163.com.''."\r\n";foreach (array(1,2,3) as $value){ $xml .= "\t".''.$value.''."\r\n";}$xml .= ''."\r\n";$sxe = <p>+本文来源gao!%daima.com搞$代*!码9网(</p><strong>搞gaodaima代码</strong>new SimpleXMLElement($xml);$sxe->asXML(APPPATH.'user.xml');
生成了user.xml文件,我现在要想添加一个:
李四
该怎么添加啊,前面跟”\t” ,后面跟”\r\n” ?
感谢~~
——解决方案——————–
- PHP code
$sxe = new SimpleXMLElement($xml);$sxe->addChild('username', '李四');$sxe->asXML(APPPATH.'user.xml');