For XML operations in PHP, I used php to generate the following xml: PHPcode $ xml & lt ;? Xmlversion & quot; 1.0 & quot; encoding & quot; UTF-8 & quot ;? & Gt;. & quot; rn & quot; $ xml. & lt; user & gt;. & quot; rn & quot; $ xml. & quot php xml operation problems
I use php to generate xml as follows:
PHP code
$xml = '
'."\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 = new SimpleXMLElement($xml);$sxe->asXML(APPPATH.'user.xml');
The user. xml file is generated. now I want to add one:
Li Si
How can I add it? I followed "\ t", and I followed "\ r \ n "?
Thanks ~~
------ Solution --------------------
PHP code
$ Sxe = new SimpleXMLElement ($ xml); $ sxe-> addChild ('username', 'Lee si'); $ sxe-> asXML (APPPATH. 'user. XML ');