Wednesday, November 14, 2012

Answers > Is It Possible to Add Elements to an Xml File Permanently Using Javascript?

Is It Possible to Add Elements to an Xml File Permanently Using Javascript?

by nForms on December 10, 2011

I am using the examples on w3schools and as far as i can tell creating or adding an element with javascript only makes that element accessible through javascript. I want to actually write a new element in to my XML file. How can i do this?

Tags: , , ,

Similar XForms | XML Posts

{ 2 comments… read them below or add one }

Calvin K April 28, 2011 at 4:46 pm

Javascripts don’t have access to files, Period.
You can’t write to a file using javascript.

But there are some workaround.
You can use XMLHttpRequest object(Ajax) or
You can use filesystem object in Windows Scripting Host or Internet Explorer in a trusted environment.

http://www.javascripter.net/faq/fileacce.htm

meander365 April 28, 2011 at 4:46 pm

You’ll need some kind of server side language (ASP,PHP) to perform this for you.

Write a small piece of server side code that accepts parameters and which then performs your permanent change to your xml file. Call the .asp or .php file using an ajax request in javascript.

Previous post:

Next post: