Php xml operations

Source: Internet
Author: User
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 ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.