I have an xml file (Student.xml) like this
<student>
<studentinfo>
<name>
<first>John</first>
<last>Doe</last>
</name>
<gender>male</gender>
</studentinfo>
</student>
and my php code
<?php
$dom = new DOMDocument;
$dom->load('Student.xml');
$student = $dom->documentElement;
$studentinfo = $student->getElementsByTagName('first')->item(0);
$newName = $student->createTextNode('Jame');
$student->replaceChild($newName, $student);
?>
I can not replace my data inside, please help me to solve this problem?