Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

726 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