How do I create this type of XML output using PHP?
<Root>
<base> rushi </base>
<base> stack </base>
<base> overflow </base>
<root>
Here is line by line code..Hope this will help you
$employees = array(
'0'=> array(
'name' =>'abin',
'age' => '23',
),
'1' => array(
'name' => 'savin',
'age' => '24',
)
);
//$file = fopen('file.xml','w');
$xml = new SimpleXMLElement('<employees></employees>');
foreach($employees as $employ):
$xml->addChild('name',$employ['name']);
$xml->addChild('age',$employ['age']);
endforeach;
file_put_contents('file.xml',$xml->saveXML());
?>tag and just write it down. Please be more specific what kind of solution you are looking for. On a sidenote, your XML is invalid. The root node is not closed. XML is case-sensitive.