if($docheader != "<?xml version=\"1.0\"?>")
new errror("You did not provide a valid xml file");
Unnecessary; if it's not a valid XML file then simplexml_load_file() will fail on the very next line anyway; where....
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
The error message may be wrong - it may have that line at the top but it may not be a valid XML file. So it should give the same error message as the previous test. In fact, it probably is wrong - as far as the user is concerned the file was loaded. In other words, all three lines could be replaced by
$xml = simplexml_load_file($file) or die ("You did not provide a valid XML file.");
and the error message would be more useful.
TWD wrote:Second I check all the fields that we are pulling out to make sure they fit certain size requirements and don't contain any nasty characters <> and ' " to be specific.
Why worry? Use htmlspecialchars() when displaying the data and they won't be an issue (you forgot that & has a special meaning in HTML pages, by the way). If the output is corrupt then the only person who will be disadvantaged would be the person who posted the corrupted data. (I guess the same would go for the error message, which contains the corrupted data nasty characters and all). Of course, assuming that the uploaded XML document is indeed a well-formed XML document (which it would need to be if it is to be parsed in the first place), all such escaping would have already taken place.
You also make no attempt to verify that any of the elements you look for (DisplayDevices, etc.) actually exist in the uploaded document before using them; however, if they don't, then that is caught because the resulting array value is the empty string; it still makes for generating a bunch of Notice messages before getting that far, though (and it means that again the error message is incorrect).