tags:

views:

489

answers:

5

Hi friends,

I need to edit a xml file using javascript. Now i involved in a project of online test.

The question.xml file is already in the project folder.

In that i want to add or edit the questions(only using javascript). I can able to bring the particular content through ajax but i cant able to edit the file.

Please help me to edit the xml file. Suggestion me some idea.

Thanks in advance

+5  A: 

Javascript can't write to a file. The best you'll be able to do is get Javascript to read and edit the XML then post that data to a server-side script to write to file.

nickf
A: 

Nickf is correct. The reason Javascript can't write to a file is because it is a Client-Side language. Javascript will never have permission to write a file because it has to operate inside the browser sandbox.

You will need to use a server-side script (.NET, PHP, ColdFusion, etc) to write the file.

discorax
A: 

If you are willing to use Google Gears, you get a sandbox on the client machine on which you can write files.

Yuval F
A: 

Javascript has no built-in file I/O (a.k.a. you can't do it with JS alone)

Instead use some kind of server side language such as PHP or ASP.NET in conjunction with Javascript's AJAX functionality.

Andrew G. Johnson
nitpicking a little bit here, but you're not right about the File IO thing. it does have file INput, just not OUTput.
nickf
A: 

Look over Adobe's Flex development system. There are ways you can use it to build an app that runs in the browser (or not) and can access the filesystem (Windows/Mac/Linux). It's programmed in ActionScript, a dialect of javascript; and can interoperate with javascript in the browser.

le dorfier