tags:

views:

1651

answers:

3

Hi friends,

How do i create new xml file and also modify any xml file means add more nodes in xml file using javascript.?

Thanks in advance...

+1  A: 

What context is the file running in, and where are you going to save the new XML data?

(The usual context is the browser, in which case you're basically able to display it or post it back to the server.)

But if you're writing a script that would run outside the browser, it depends.

Daniel Earwicker
i am getting data of the google map, and need to store in xml file,and from the xml file i need to create map based on xml element..
Avinash
Okay, I guess that means you're running in the browser (though it isn't necessarily so). And when you store the XML file, where do you want to store it? (In the file system of the computer where the browser is running? At the server where the page was served from?)
Daniel Earwicker
i need t store it on server..
Avinash
A: 

AFAIK you can't really create a new xml file with client-side Javascript, usually this is done through a server-side language ( Javascript can be used for server side but it's a rarity ).

Is there any particular reason why you can't go with PHP or Python to create the xml file?

meder
yes my main application is running on PHP..
Avinash
If you can retrieve the google map data with server-side, then you can create an xml file. If you can't, with the data from PHP you could make an XHR ( Ajax ) http request and send the data to a server-side page which can then create/modify an xml file.
meder
yes i m thinking of doing that now..
Avinash
A: 

In IE you can manipulate XML using an ActiveX.
There is also a built in object for FF and other W3C complient browsers.
I recommend you to take a look at this article.

the_drow
Nice article thanks it teach me a lot..
Avinash