I am writing a new record to xml file with to item , A English word and a Hebrew word.
But the line $newWord->appendChild($prop.$new_line);
causes this Error
"Object of class DOMElement could not be converted to string"
the parameter $new_line equal to $new_line = "
";
.
what I miss here thx ?
my code are:
<?php
/*$wordH=$_GET['varHeb'];
$wordE=$_GET['varEng'];*/
$wordH="newhebWord";
$wordE="newengWord";
$new_line = "
";
$doc='';
if(!$doc)
{
$doc = new DOMDocument();
// we want a nice output
$doc->formatOutput = true;
$doc->load('Dictionary_user.xml');
}
$Dictionary_user = $doc->documentElement;
$newWord = $doc->createElement('newWord');
$prop = $doc->createElement('Heb', $wordH);
$newWord->appendChild($prop.$new_line);
$prop = $doc->createElement('Eng',$wordE);
$newWord->appendChild($prop.$new_line);
$Dictionary_user->childNodes->item(0)->parentNode->insertBefore($newWord,$Dictionary_user->childNodes->item(0));
header("Content-type: text/xml");
$doc->save("Dictionary_user.xml");
echo $doc->saveXML();
?>