Client-side fixes for this problem are difficult to implement so they are completely bulletproof. What if, for example, the file is not empty but half-way written when the client reads it? The best solution is to fix the server so that it never delivers a partially written file. The normal way to do this, at least for Linux/Unix-like systems, is to write the new XML file to a temporary file, then after it is completely written and closed, atomically rename it to the correct name.
--Mark