By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

concatonate 2 xml files via Javascript

P: 25
Is it possible to combine 2 xml files to make one xml file using JavaScript? I need to concatonate one xml file to the end of another xml file to make one file to be read by this possible through javascript?

Aug 6 '08 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 5K+
P: 5,343
i'm not familiar with flash ... how would flash read the xml-file? in case it is able to use a javascript-reference to an xml-document (basicly a document in the memory) then it would be possible but in case you need a physical xml-document written to the file-system ... it is not ...

kind regards
Aug 7 '08 #2

Expert Mod 15k+
P: 16,027
Are the XML files local or on the server? If they're local, then what gits says applies unless you use a browser-specific solution, e.g. ActiveX, Mozilla privileges. If they're on the server, use a server-side language to combine them into one. If you need this to happen client-side, make an Ajax request to a server-side script.
Aug 7 '08 #3

P: 25
this would be done client side...the xml files, flash swfs, and html will all be on the server in the same location...preferrably i would want the html file to use some sort of javascript to concatenate the two xml files before it calls the flash swf...what would I need to do this?
Aug 7 '08 #4

rnd me
Expert 100+
P: 427
you can change a file on your server, called eg: temp.xml, to public write. for a.xml this shouldn''t be too dangerous: browser will display the tree, and flash will take care of itself.

you would then have a cross-browser way of saving the data to the server with a simple ajax PUT.

xml is xml, dosn't matter who the endpoint consumer is.

i would recommend creating a new document, and then loading each xml file, raking out the nodes you need, copying them to the new document. do that for both files, publish the new xml file, and send it to flash.

if you don't care about IE compatibility, you might be able to avoid a server-write by using the data: url scheme. you can easily turn a string unto a dataURL that acts like a file outside of IE. not sure if flash supports dataURLs, but if it did, it would be lightning fast and cheaper to serve.

run thorugh an xml tutorial or two focusing on creating new documents, and you should be able to mange sample code to get your job done. i bet there's even sample code out to merge two files. google it.
Aug 7 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.