0

mgwt を使用してモバイル アプリを構築しています。このアプリは、コンテンツが xml ファイルから取得されたリストで構成されています。アプリを使用して、これらの xml ファイルに新しいコンテンツを追加しようとしています。

xml ファイルは次のとおりです。

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <options>
            <option>c1 A</option>
            <option>c1 B</option>
    </options>
 </root>

新しいものを追加しようとしています

<option>c1 C </option>

< options > 親内のタグなので、結果は次のようになります。

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <options>
            <option>c1 A</option>
            <option>c1 B</option>
            <option>c1 C </option>
    </options>
 </root>

次のコードで試していますが、何も起こりません。

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL()+"folderName/fileName.xml");
    try{
        builder.sendRequest(null, new RequestCallback() {

            @Override
            public void onResponseReceived(Request request, Response response) {
                Document document = XMLParser.parse(response.getText());


                Element elementRoot = document.getDocumentElement();

                Element options = (Element)elementRoot.getElementsByTagName("options").item(0);

                Element optionElement = document.createElement("option");
                optionElement.appendChild(document.createTextNode("c1 C"));

                options.appendChild(optionElement);

            }

            @Override
            public void onError(Request request, Throwable exception) {

            }
        });
    }catch(RequestException e){
        Window.alert("Unable to build the request.");
    }

なにが問題ですか?助けてください。

4

1 に答える 1