I want to create an XML
document of this type:
<?xml version="1.0" encoding="UTF-8"?>
<libreria version="1">
<libri>
</libri>
</libreria>
and then insert in various other fields like <libro><data></data></libro>
.
I created the following code:
<?php
$note=<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<libreria version="1">
</libreria>
XML;
$mioArray = new SimpleXMLElement($note);
$result =$mioArray->addChild('libri');
$result2 = $result->addChild('libro');
$result2->addChild('data', 22);
echo $result2->asXML();
?>
But when print the output, I don't see the first part in this $notes
.
What am I doing wrong?