ID: 26083
Updated by: [email][/email]
-Summary: save function isn't working
Reported By: daju at passagen dot se
-Status: Open
+Status: Feedback
Bug Type: DOM XML related
-Operating System: Windows XP Home
+Operating System: Linux
-PHP Version: 5CVS-2003-11-02 (dev)
+PHP Version: 4.3.3
New Comment:

are you sure, the file is writable.

The method just returns false in your case, which means, it couldn't
write for whatever reason.


Previous Comments:

[2003-11-06 13:37:37] daju at passagen dot se

Yes, only when destination file already exist. But that's the point.

If I want to update a xml file I already have using DOM then I can't
use save() function to save my changes.

Shouldn't save() function work as DomDoent->dump_file() in PHP


[2003-11-05 11:44:32] [email][/email]

The problem with saving only occures when the destination file already


[2003-11-02 13:57:25] daju at passagen dot se

Hi folks,

I just downloaded development version av PHP 5 (CVS 2003-11-02) and
tried the new DOM functions that uses libxml2 library. It's working
great but there is one thing that I don't understand.

I tried to update a xml file I have and I can add nodes and attributes
but when i try to save file then nothing happens. There is no error
messages at all.

How ever if I choose another file name for the save function then it is
working. New file is created and I see both the old and the new nodes
in the xml file.

Am I missing something here?

Reproduce code:
echo "<h3>Just a simple DOM test</h3>";

$dom = new domDoent();
$load = $dom->load('test.xml');
$root = $dom->doentElement;

$element = $dom->createElement("temp", "Just a test text");
$attr = $element->setAttribute("id", "0007");
$attr = $element->setAttribute("author", "darren");
$tmp = $root->appendChild($element);

$tmp = $dom->save('test.xml');
echo $tmp." bytes was saved to the xml file.";

Expected result:
The file should be updated. Output i my browser should be:

363 bytes was saved to the xml file.

Actual result:
0 bytes was saved to the xml file.


Edit this bug report at [url][/url]