I want to create XML file in php and I have saved the values from array to variable
<?php
$name = $e['name_1'];
$email = $e['email_id'];
$phone_no =$e['phone_no'];
$doc = new DOMDocument();
$doc->formatOutput = true;
$ele1 = $doc->createElement('StudentName');
$ele1->nodeValue=$name;
$doc->appendChild($ele1);
$ele2 = $doc->createElement('FatherEmailId');
$ele2->nodeValue=$email;
$doc->appendChild($ele2);
$ele3 = $doc->createElement('PhoneNumber');
$ele3->nodeValue=$phone_no;
$doc->appendChild($ele3);
$doc->save('MyXmlFile007.xml');
?>
i want my XML formatted lik this
<?xml version="1.0"?>
<StudentDetails>
<StudentName>Pravin Parayan</StudentName>
<FatherEmailId>pravinp@pigtailpundits.com</FatherEmailId>
<PhoneNumber>9000012345</PhoneNumber>
<StudentDetails/>
But instead of the above i get something lik this
<?xml version="1.0"?>
<StudentDetails/>
<StudentName>Joel George</StudentName>
<FatherEmailId>joy@pigtailpundits.com</FatherEmailId>
<PhoneNumber>9000012345</PhoneNumber>