concatonate 2 xml files via Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paulcybulski
    New Member
    • Nov 2007
    • 25

    concatonate 2 xml files via Javascript

    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 flash...is this possible through javascript?

    Thanks,
    Paul
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    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

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      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.

      Comment

      • paulcybulski
        New Member
        • Nov 2007
        • 25

        #4
        this would be done client side...the xml files, flash swfs, and html will all be on the server in the same location...pref errably 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?

        Comment

        • rnd me
          Recognized Expert Contributor
          • Jun 2007
          • 427

          #5
          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.

          Comment

          Working...