Originally posted by nitm
i'm new here and new with php so sorry for that...
Is not a problem; just giving you a heads-up early so that you don't accidentally annoy people in the future (me, I'm a grumpy old codger who gets annoyed by the sun coming up every single morning).
let's start with the php itself, i don't know which version of php i'm using because it's not on my computer.. i'm doing this script for a friend and i'm doing everything on his server (host: media temple).
There's a function, [man]phpversion[/man] that will supply this. I ran your code on a couple of different versions (5.0.3 and 4.3.10) and it worked in 4.3.10, but not in 5.0.3 (I had a look in bugs.php.net, and there may be a bug involved, though I'm not sure. But if you are using PHP 5.something, the DOM-XML extension is deprecated in favour if PHP5's inbuilt [man]DOM[/man] library instead).
i want to use only the xml dom functions and well, that is installed for sure because i don't get any error messages.
When I ran your code in 5.0.3., I got error messages that culminated in a Fatal Error. Your host may have turned off error display (if this is a live site, display_errors should be turned off), and the error messages are being logged somewhere instead. Put an extra command
ini_set('display_errors','1');
at the start of your code, just to see.
i know that the script opens the existing xml file with the parser, the problem is the saving part...
i've been sitting on the docs all nite to understand what's wrong, i didn't find it... as i see it the script is good but it just won't save the xml to the file.... i don't get any error messages though.
Did you try dumping it to the screen (using dump_mem to instead of dump_file to put it in a variableand then printing the contents of the variable)? Because of all the tags, you'd probably want to view the resulting source directly, because of couse an HTML renderer ignores tags it doesn't recognise. My test blah.xml read
<blah><foo>pink</foo></blah>
and the output in 4.3.10 was
<?xml version="1.0"?>
<blah>
<foo>pink</foo>
</blah>
<entry id="1"/>
which I have to point out isn't valid XML (I think you want the entry element to be inside the root element).
i think that maybe the problem is that i don't give the exact path to the file.. can that be?
Unless your error display is turned off (see above) you'd get an error message about the file not being found. To find out where PHP looks for files, use [man]ini_get/man; (and while we're on the subject, a whole pile more diagnostic information can be fetched all at once with [man]phpinfo[/man].
how do i get the path of the directory where the script runs?
something like the Server.MapPath in asp.
All these and more are in the $SERVER array: $SERVER['SCRIPT_FILENAME'] is probably what you're after (it's been years since I touched ASP or VBScript).