Forums > Javascript

Write an XML file

November 17, 2006 | 6:30 pm

Dear all, I would like to write a function that, given an array of tag-names and an array of values, just writes an XML file on the disk.

How can I do that?

Regards,
Bruno

————————————————-
- http://www.brunozamborlin.com -
————————————————-


November 17, 2006 | 7:10 pm

With Javascript and

http://xmljs.sourceforge.net/

Also I think jasch has some xml objects

http://www.jasch.ch/

Cheers

-A


November 17, 2006 | 7:51 pm

Quote: Andrew Pask wrote on Fri, 17 November 2006 20:10
—————————————————-
> With Javascript and http://xmljs.sourceforge.net/

Thank you very much.
Hovewer, I already tried to use this library for saving an XML file on hardisk, using the "xmlIOSaveData" function. My code was:

function prova (val){
var xml = ""
+ "< ?xml version="1.0"?>"
+ ""
+ ""
+ ""
+ "value"
+ "
"
+ "
"
+ "
";
//save the xml to the client’s hard drive until Jan 1, 2003
var expDate = new Date("January 1, 2003");
xmlIOSaveData("savedXML", xml, expDate);

}

but I had this error:

• error: js: BXMLEditor: Javascript ReferenceError: document is not defined, line 255
• error: js: error calling function prova

In the line 255, the code was:

document.cookie = dataName + "=" + escape(dataValue) + " ;expires=" + expireDateGMT;

That could means, I think, that Max cannot store cookies…

> Also I think jasch has some xml objects
>
> http://www.jasch.ch/
>

I downloaded it, which object in particular should help me?

Best regards,
Bruno

————————————————-
- http://www.brunozamborlin.com -
————————————————-


November 18, 2006 | 2:01 am

If you already have the file in the format you like then just write it to disk using the File Object. This is what you would do after creating a file using methods from the js XML libs.

Check out maxobjects.com for more xml externals. Tim Place has some stuff in taptools as well.

-A


Viewing 4 posts - 1 through 4 (of 4 total)