Editing a file with javascript
I need to edit the xml file using javascript. I am now participating in an online testing project.
The question.xml file is already in the project folder.
Is that I want to add or change questions (using javascript only). I can pass specific content via ajax, but I cannot edit the file.
source to share
So far, Google Chrome is the only web browser that has a functional implementation of the FileSystem API, so it can let you save files locally using only Javascript.
Obviously, for security reasons, when writing files to the local file system, the user must explicitly allow this.
Working tutorial: http://www.html5rocks.com/en/tutorials/file/filesystem/
source to share
Nickf is correct. The reason Javascript cannot write to file is because it is Client-Side . Javascript will never have write access to the file as it needs to run in the browser sandbox.
You will need a server-side script (.NET, PHP, ColdFusion, etc.) to write the file.
source to share
If you want to use Google Gears , you get a sandbox on the client machine that you can write files to.
source to share
Take a look at the Adobe Flex development system. There are ways to use it to create an application that runs in a browser (or not) and can access the file system (Windows / Mac / Linux). It is programmed in ActionScript, a javascript dialect; and can interact with javascript in the browser.
source to share