SimpleXMLElement creating two XML Tags



I'm building xml with the SimpleXMLElement Object from PHP.


While doing so I encountered the following problem, which i can't solve:


I'm generating the root xml element like this:



$xml = new SimpleXMLElement("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");


But i get a 2 XML headers when i do echo $xml->asXML(); like this:



<?xml version="1.0"?>
<xml version="1.0" encoding="UTF-8"></xml>


Which is obvioulsy wrong. But how can i fix this so i only get the



<xml version="1.0" encoding="UTF-8">


part?


No comments:

Post a Comment