Solved

How to save the xml file after I've been using DOM?

Posted on 2003-11-10
2
361 Views
Last Modified: 2012-05-04
Hi!

I've read the DOM tutorial at w3-schools, and I wonder how I can save the xml file which I've have appended elements to.

My html file is:

<html>
<body>

      <script type="text/vbscript">

      set xmlDoc=CreateObject("Microsoft.XMLDOM")
      xmlDoc.async="false"
      xmlDoc.load("cust.xml")

      document.write("The original XML:")
      document.write("<xmp>" & xmlDoc.xml & "</xmp>")

      set newnode=xmldoc.createElement("cancel")
      xmldoc.documentElement.appendchild(newnode)

      document.write("After appending the new node:")
      document.write("<xmp>" & xmlDoc.xml & "</xmp>")
      xmlDoc.save("cust.xml")
      </script>


      
</BODY>
</HTML>

When I start it I get the error:
Error: Permission denied: 'xmlDoc.save'

I have shared the directory in which these two files are (cust.xml and my html page)

Can anyone help me out?

Thanks in advance!

Best regards,
Tom-Erik
0
Comment
Question by:tomerikv
[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
2 Comments
 
LVL 26

Accepted Solution

by:
rdcpro earned 70 total points
ID: 9723819
You can't do this from an HTML page loaded from a web server.  Security restrictions.  If the HTML page is local (as it sounds like it is) you can rename the page to *.hta.  This will override the security restrictions in HTML pages.  HTA (HTML Applications) run in an elevated security context, but you'll notice the browser toolbar and menus are gone.  You have to implement these yourself in the page.  If you eventually have to serve this from a web server, you'll run into problems.

I think you can do this in an HTML page if it's loaded from the local filesystem, but you have to mess with the security of the local folder...I can't recall for sure how, or if it's even possible.  I always use HTA's when trying stuff like this.

By the way, use MSXML 3, not 2.  Change:

    set xmlDoc=CreateObject("Microsoft.XMLDOM")
to:
    set xmlDoc=CreateObject("Msxml2.DomDocument")

especially in this case, where you know what the environment is.


Regards,
Mike Sharp



0
 
LVL 1

Author Comment

by:tomerikv
ID: 9725139
Hi!

Thanks a lot!

It worked!

Best regards,
Tom-Erik
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …

739 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