首页 > 解决方案 > Javascript write to local XML file

问题描述

I know there are several questions how to save changes in an XML file using Javascript, and the obvious answer is: use a server side language such as PHP.

In my case, the XML file is in the same directory as my html file locally on my computer, not on any server.

In my index.html I access the alphabets.xml this way:

function getAlphabets() {
    var xhttp;var result;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            result = findAlphabets(this);
            console.log(result);

        }
    };
    xhttp.open("GET", "alphabets.xml", true);
    xhttp.send();
}

I want to change some data in the xml file, and save it back there. Is there any possible way to do so in plain javascript?

Or another way, not using a server side language?

标签: javascriptxml

解决方案


推荐阅读