I tried to update xml node value by posted PHP value. My problem, after save the XML, can look like
<name>test
test123</name>
My expect result is
<name>test
test123</name>
My source
$xml_Document = new DOMDocument();
$xml_Document->load('test.xml');
$employees = $xml_Document->getElementsByTagName("employees");
foreach( $employees as $employee )
{
$names = $employee->getElementsByTagNa开发者_如何学运维me("name");
$names->item(0)->nodeValue = $_POST["text1"];
}
$xml_Document->save('test.xml');
I think this will fix your problem $names->item(0)->nodeValue = str_replace(chr(13), '', $_POST["text1"]);
精彩评论