"Error while parsing the document" .. Hvorfor fejler den der?
<?php
//Creates XML string and XML document using the DOM
$dom = new DomDocument('1.0');
//add root - <profiler>
$profiler = $dom->appendChild($dom->createElement('profiler'));
//add <profil> element to <profiler>
$profil = $profiler->appendChild($dom->createElement('profil'));
//add <navn> element to <profil>
$navn = $profil->appendChild($dom->createElement('navn'));
//add <navn> text node element to <navn>
$navn->appendChild(
$dom->createTextNode('Bo'));
//generate xml
$dom->formatOutput = true; //set the formatOutput attribute of domDocument to true
//save XML as string or file
$test1 = $dom->saveXML(); //put string in eksempel1
$dom->save('test1.xml'); //save as file
?>
<?php
$sxe = simplexml_load_string('<profiler><profil><navn>'.'Bo</navn></profil></profiler>');
if ($sxe==false) {
echo 'Error while parsing the document';
exit;
}
$dom_sxe = dom_import_simplexml($sxe);
if(!dom_sxe) {
echo 'Error while converting XML';
exit;
}
$dom = new DOMDocument('1.0');
$dom_sxe = $dom->importNode($dom_sxe, true);
$dom_sxe = $dom->appendChild($dom_sxe);
echo $dom->save('test2.xml');
?>