Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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, …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

27 Experts available now in Live!

Get 1:1 Help Now