I have used SimpleXMLElement for creating xml But it cannot handle &. Here is my code
$contacts = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><Contacts></Contacts>');
$name = $contacts->addChild('name', 'You & Me');
$name->addAttribute('no', '1');
echo $contacts->asXML();
And here is the output
<?xml version="1.0" encoding="UTF-8"?>
<Contacts><name no="1">You </name></Contacts>
How to solve this Question. I want a solution for all special character.