1

Linux Apache サーバーで PHP5 を実行しています

Web サイトで XML を単純なデータベースとして使用しようとしています。

整数 (ノードの内容) を 1 増やして、ファイルを保存する必要があります。

エラーメッセージは次のとおりです。未定義のメソッド SimpleXMLElement::replaceChild() への呼び出し

これが私のコードです:

<?php
$x = $_GET['x'];
$y = $_GET['y'];
$z = $_GET['z'];        
$dom = simplexml_load_file("questions.xml");
if ($dom->question['id'] == $x) {
    $poll = $dom->question->poll;
    if ($z == 0) {
        $yes = $poll->yes;
        $upper = $yes + 1;
        $yes->replaceChild($yes, $upper);
    } elseif ($z == 1) {
        $no = $poll->no;
        $lower = $no + 1;
        $no->replaceChild($no, $lower);
    }
}
?>

質問.xml

<?xml version="1.0" encoding="utf-8" ?>
<questions>
    <question id="does-god-exist">
    <poll>
        <yes>0</yes>
        <no>0</no>
    </poll>
    </question>
</questions>
4

2 に答える 2