0

I wish to create a simple web application to run in the browser that can alter a local XML document I.e. user inputs a word that will replace a specific word in the doc.

Is this the correct approach to load the doc? I then intend to use JS to alter it?

Current Code:

<!DOCTYPE html>
<html>
<body>

    <h1>XML EDITOR</h1>

    <form>
       Enter word to edit in xml doc: <input type="text"><br>
       <input type="submit" value="Submit">
    </form> 

    //add js to alter the word within form...


    </html>
  • Yes, but that submit button will screw everything up, because once you click it it will refresh the document, hence you will lose everything done until now unless you are pointing a server-side script that will LOAD the xml document (and, at this point, it is useless to load that on the client side). Do you want to send back that xml document or..? – briosheje May 28 '15 at 08:36

1 Answers1

0

You can't alter local files with Javascript, due to security reasons.

Imagine the contrary: while you browse on a site, a script in background scans your harddrive, copying all your files. It would not be that good, uh ?

What you need is a Java program, eg. with a Swing GUI, not a Java web application.

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • Thanks. Can I load the document as string in HTML then use JS to find and replace words within the string? I just am not sure how to load the document? – user4929435 May 28 '15 at 08:45
  • Sure, you can let the user UPLOAD the document, then allow them to manipulate it, and finally to DOWNLOAD it again. But that's not altering a local file ;) You need an ``, and probably some HTML tutorial – Andrea Ligios May 28 '15 at 08:47
  • Thanks, are you aware of any html tutorial for this? – user4929435 May 28 '15 at 08:52
  • I'm sorry, but no... I've studied this in the previous millennium :| – Andrea Ligios May 28 '15 at 09:22