Ok this is what I have now, is this right? I can't seem to use the post data for some reason though, I think because it is an array?? Or maybe this whole thing is wrong??
$filename = array();
foreach ($POST['filename'] as $key=>$value) {
$filename[$key] = $POST['parentnav'][$key];
$xml = simplexml_load_file("$docroot/admin/xml/string($POST['filename'])");
$xml->parentnav[0] = string($POST['parentnav']);
$xml = $xml->asXML(); // returns the SimpleXML object as a serialized XML string
$file = fopen("$docroot/admin/xml/string($POST['filename'])","wb");
fwrite($file,$xml);
chmod("$docroot/admin/xml/string($POST['filename'])",0777);
fclose($file);
}