View Full Version : How to use JavaScript to read/write XML locally?

09-01-2008, 12:39 AM
I have an html page installed on the client.
Also, I have an XML page installed on the client.
The user loads the html page to view the XML data in a browser (Firefox).

I am using JavaScript to read the XML file.

Now I would like the user to be able to add, edit or delete nodes from the XML file (creating a mini database that can be updated by the user).

Is this possible?

09-01-2008, 05:58 PM
My gut instinct is that this is only really possible with php, though I might well be wrong.

I've done somthing similar in the past and I wrote a simple php script that read the XML file and echoed out a javascript array of the data.

The client then uses/manipulates this data using Javascript.

Upon 'saving' the alterations made, the page posted the javascript array to another php script which wrote the changes to the XML file.

...A similar process might be your best bet (though if this is possible using JS, I'd love to know how!)

09-01-2008, 11:55 PM
I hope it can be done in JS. The reason I am not using PHP is this is really not a web app. I am simply using the browser as the interface for the JS-powered database editor. So everything is run locally (no server involved = no PHP).