php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26083 Problem with uri-string in function xpath_register_ns()
Submitted: 2003-11-02 13:57 UTC Modified: 2003-11-07 14:16 UTC
From: daju at passagen dot se Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4.3.3 OS: Linux
Private report: No CVE-ID:
 [2003-11-02 13:57 UTC] daju at passagen dot se
Description:
------------
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:
---------------
<?php
    echo "<h3>Just a simple DOM test</h3>";

    $dom = new domDocument();
    $load = $dom->load('test.xml');
    $root = $dom->documentElement;

    $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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-05 11:44 UTC] iliaa@php.net
The problem with saving only occures when the destination file already exists. 
 [2003-11-06 13:37 UTC] 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 DomDocument->dump_file() in PHP 4.3.x?
 [2003-11-07 12:00 UTC] chregu@php.net
are you sure, the file is writable. 

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

chregu
 [2003-11-07 14:16 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 14:02:18 2014 UTC