query('//game[@id="' . $id . '"]')->item(0); $xpath->query('//game[@id="' . $id . '"]/name')->item(0)->nodeValue = $name; $xpath->query('//game[@id="' . $id . '"]/author')->item(0)->nodeValue = $author; $xpath->query('//game[@id="' . $id . '"]/thumbnail')->item(0)->nodeValue = $thumbnail; $xpath->query('//game[@id="' . $id . '"]/magazine')->item(0)->nodeValue = $magazine; $_SESSION["eid"] = null; } else { $root = $doc->getElementsByTagName("root")->item(0); $game = $doc->createElement("game", ""); $mid = $doc->getElementsByTagName("mid")->item(0); $game->setAttribute("id", $mid->nodeValue); $mid->nodeValue = intval($mid->nodeValue) + 1; $count = $doc->getElementsByTagName("count")->item(0); $count->nodeValue = intval($count->nodeValue) + 1; $game->setAttribute("order", $count->nodeValue); $name = $doc->createElement("name", $name); $author = $doc->createElement("author", $author); $thumbnail = $doc->createElement("thumbnail", $thumbnail); $magazine = $doc->createElement("magazine", $magazine); $game->append($name); $game->append($author); $game->append($thumbnail); $game->append($magazine); $root->appendChild($game); } $doc->save($path);