Solved

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

Posted on 2003-11-10
2
354 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
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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, …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now