"changing xml-file using php"-problem

I’m combining flash, php and xml to make an online game. When you play the game and enter a room, you load a php-script that gets data from the swf and then rewrites a xml-file.

The problem is that when two users call the php script somewhat at the same time, one of them will not be recorded because the other will overwrite the file with the adapted old file.

Are there any ways around this? I don’t think you can change an xml file (using php) without rewriting it, is it possible to change for instance the value of an attribute?

Hope I’m making sence.