I am new to PHP and I want to edit XML files using PHP. When I add child in my xml file I don't get them in proper formatted way. This is creating log of trouble in further editing in the file. Please help me edit my xml file so that the resulting xml is well formatted.Thanks in advance.I am editing my xml file using this code\[code\]<?php$xml_file = simplexml_load_file('editing.xml');$xml_file->formatOutput = true;$xml_file->preserveWhiteSpace = false;$xml_file->addChild('article',' ')->addAttribute('id', 'id3');file_put_contents('editing.xml', $xml_file->asXML());?>\[/code\]This is the xml file I am using.\[code\]<?xml version="1.0" encoding="utf-8"?><userva> <user id="BPL000001" first_name="f_name" last_name="l_name"> <article id="wersomething"> <title>Some title</title> <description>he does play well all the time</description> <posted_on>11/Nov/2012</posted_on> <text_contents>Some contents.. Some Contents..Some contents.. Some Contents..Some contents.. Some Contents..</text_contents> <images> <image>image1.jpg</image> <image>image2.jpg</image> </images> <links> <link>link1</link> <link>link2</link> </links> <likes> <like>like11</like> <like>like12</like> <like>like13</like> <like>like14</like> <like>like15</like> </likes> <comments> <comment by="523423440"/> <comment by="054232130"/> <comment by="15849584200"/> </comments> </article> <article id="id2"> <title>Some title</title> <description>he does play well all the time</description> <posted_on>95956262</posted_on> <text_contents>Some contents.. Some Contents..Some contents.. Some Contents..Some contents.. Some Contents..</text_contents> <images> <image>imageva1.jpg</image> <image>imageva2.jpg</image> </images> <links> <link>link1</link> <link>link2</link> </links> <likes> <like>like21</like> <like>like22</like> <like>like23</like> <like>like24</like> <like>like25</like> </likes> <comments> <comment by="0142264340"/> <comment by="0523412130"/> <comment by="5523484200"/> </comments> </article> </user></userva>\[/code\]