?
Solved

Saving locally through the browser?

Posted on 2002-03-06
12
Medium Priority
?
181 Views
Last Modified: 2011-09-20
Greetings,

What I currently have is a XML editor in browser. I wish to do is allow the user to save the XML file to their local machine. Does anyone know how or if this is possible?

TIA

MistaBiggz
0
Comment
Question by:MistaBiggz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6845031
They can save the html page.  They can cut and paste to a text file or they can download a file from the server and save it.  If they are editing a file form the server, then it has to be saved back to the server and then they can download it.  

I think that about covers the options, unless there is activex or a plugin involved.

Cd&
0
 

Author Comment

by:MistaBiggz
ID: 6845156
I'm utilizing servlets and JavaBeans in this application so I can save the file to the server. Is there a way to instantiate the "Save to Disk" dialogue without having the user click on a link to the file on the server?
0
 
LVL 19

Expert Comment

by:webwoman
ID: 6845235
Not really. You want them to save it, there has to be a link of some kind or they need to have the page open.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6845597
Unfortunately, there is no way to do any sort of binding across the pages.  So you will have to come back with the link so they can do a conventional save. Once the browser sends the save to the server is becomes dumb until the server sends back something for it to process.

Cd&
0
 
LVL 3

Expert Comment

by:malcx
ID: 6846721
Use a signed applet or activeX controls to save to a local disk on the users machine.
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6850806
    <html>
          <head>
               <script language=vbscript>
                    sub download
                         set vDoc = createobject("Scripting.FileSystemObject")
                         set vStream = vDoc.CreateTextFile ("c:\test.xml")
                         set vframe = window.document.all("myframe")
                             
                         vStream.write vFrame.contentwindow.document.body.innertext
                             
                         
         
                    end sub
               </script>
          </head>
         
          <body>
               <a href="#" onclick="Download()">to the xml file</a>
               
               <iframe name=myframe id=myframe src="test.xml"></iframe>
          </body>
     </html>



This page does not do what you want completely, but it might be worth looking at ...

On my machine it saves the content of test.xml to a file c:\test.xml.  It says that it's unsafe (due to the filescripting object).  

So, this might help you on your way, but it's only for IE 5 and you must have the FileSystemObject installed.
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6850882
sub download
     set vDoc = createobject("Scripting.FileSystemObject")
     set vStream = vDoc.CreateTextFile ("c:\test.xml")
     set vframe = window.document.all("myframe")
                             
     vText = vFrame.contentwindow.document.body.innertext
                         
     vText = mid(vText, 3)
     vPos = 1
                         
     do
          vPos = instr(vPos + 3, vText, chr(10))
                             
          if vPos > 0 then
               vText = left(vText, vPos - 2) & vbcrlf & mid(vText, vPos + 3)
          end if
     loop until vPos = 0
                         
     vStream.write vText
end sub


This script is better  :-))
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 800 total points
ID: 6854865
clientside:

- Create an iframe:
<iframe name="fHidden" style="position:absolute;visibility:hidden;" src="about:blank"></iframe>

- add following script and call whenever necessary
<script>
function saveContent(sText, sDestination)
{
    if(document.layers) return false;
    document.frames[sDestination"].document.body.innerHTML = sText;
    document.frames[sDestination"].document.execCommand("SaveAs");
   return true;
}
</script>

- Call it like:
saveContent("<xml version=......><...>", "fHidden");
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6892547
Is this completed, or is more needed?

Cd&

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6975489
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6990031
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to CJ_S

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6990713
Comment from expert accepted as answer.

Computer101
E-E Moderator
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question