Php DOMDocument kullanarak xml veri eklemek çalışıyorum. i girin vurduğunda ancak, sadece hiçbir hatayı gösteren boş bir sayfa görüntüler. ben yanlış ne yapıyorum?
UPDATED:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$xmldoc = new DOMDocument();
if(file_exists('test.xml')){
$xmldoc->load('test.xml');
} else {
$xmldoc->loadXML('<root/>');
}
/*get the values of the html: */
$title_ar = $_POST["title_ar"];
$title_en = $_POST["title_en"];
$intro = $_POST["intro"];
$v_ar = $_POST["v_ar"];
$v_en = $_POST["v_en"];
$v_tren = $_POST["v_tren"];
/*get the values of the html: */
$root = $xmldoc->firstChild;
if ($xmldoc->getElementsByTagName("title")->length == 0) {
/* Arabic */
$el_title_ar = $xmldoc->createElement('title');
$root->appendChild($el_title_ar);
$text_title_ar = $xmldoc->createTextNode($title_ar);
$el_title_ar->appendChild($text_title_ar);
/* Arabic */
/* English */
$el_title_en = $xmldoc->createElement('title');
$root->appendChild($el_title_en);
$text_title_en = $xmldoc->createTextNode($title_en);
$el_title_en->appendChild($text_title_en);
/* English */
}
else if ($xmldoc->getElementsByTagName("introduction")->length == 0) {
$el_intro = $xmldoc->createElement('introduction');
$root->appendChild($el_intro);
$el_intro_para = $xmldoc->createElement('para');
$el_intro->appendChild($el_intro_para);
$text_intro = $xmldoc->createTextNode($intro);
$el_intro_para->appendChild($text_intro);
}
$verse = $xmldoc->createElement('verse');
$root->appendChild($verse);
/* Arabic */
$verse_p = $xmldoc->createElement('p');
$verse->appendChild($verse_p);
$v_ar_p = $xmldoc->createTextNode($v_ar);
$verse_p->appendChild($v_ar_p);
/* Arabic */
/* English Translation*/
$verse_trans = $xmldoc->createElement('trla');
$verse->appendChild($verse_trans);
$v_en_trans = $xmldoc->createTextNode($v_en);
$verse_trans->appendChild($v_en_trans);
/* English Translation*/
/* English Transliteration*/*/
$verse_translit = $xmldoc->createElement('trli');
$verse->appendChild($verse_translit);
$v_en_translit = $xmldoc->createTextNode($v_tren);
$verse_translit->appendChild($v_en_translit);
/* English Transliteration*/
/*Save the XML File*/
$xml->formatOutput = true;
$xmldoc->save('test.xml');
header("Location: index.php");
?>