Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 25th, 2005, 07:11 AM
Registered User
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to save XML file using JScript/DOM in IE

Greetings all,

I'm a new member to this group, I'm having a bit of a problem with the IXMLDocument's save method and I'm not sure how to fix it.

I have a javascript function SaveToXML in which I'll load existing xml file to msxml2.DOMDocument.4.0 object. Then I added new nodes to Root element of the XMLDoc and I'm trying to save it to the same xml file.

At the end of the script I used the line "alert(xmlDoc.xml)" to see that my XML has been revised (this is for debugging only) and then use the line "xmlDoc.save(filename)". I'm able to see my expected changes in alert but not in xml file on disk.

The problem here is XMLDoc.Save(filename) is not intended for use from a secure client, such as Microsoft® Internet Explorer. I can able to save to file from View mode in Visual Studio InterDev 6.0. Can anybody help me to save xml file using JScript and DOM without using Server objects. I put security level to low for IE 6.0 on my work station.

I am trying to do a simple GuestBook for my site using XML, almost finished this except for this problem and have wasted countless hours trying different things and scouring the web for help. If anyone out there can help me with this, I would greatly appreciate it.

Here is the function I'm using:
function WriteToXML()
    var Node
    var NodeN
    var xmlDoc, xmlPersist
    var root
    xmlDoc= new ActiveXObject("msxml2.DOMDocument.4.0")
    xmlDoc.validateOnParse = true
    xmlDoc.async = false

    root = xmlDoc.documentElement
    Node = xmlDoc.createNode(1, "Guest", "")
    nodeP = xmlDoc.createAttribute("confidential")

    NodeN=xmlDoc.createNode(1, "Name", "")

    NodeE=xmlDoc.createNode(1, "Email", "")

    NodeW=xmlDoc.createNode(1, "Website", "")

    NodeC=xmlDoc.createNode(1, "Comments", "")
    // working fine..

  xmlDoc.save("GuestBook2.xml") // can't use filename as IE won't allow
    alert("Something getting wrong")


Old April 25th, 2005, 09:07 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

Perhaps if you read the answer posted before you wouldn't have to post the question again?


Joe (Microsoft MVP - XML)
Old April 26th, 2005, 07:37 AM
Registered User
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

As per the reply in earlier question, I was trying to use HTML Component for Script, but without success.
Could you please give me a new idea.

Similar Threads
Thread Thread Starter Forum Replies Last Post
save word formfields into an xml file manjugv Word VBA 0 May 1st, 2006 04:44 PM
Can't save XMLDoc to a xml file using JScript induriprakash Javascript 2 May 13th, 2005 02:44 PM
parse xml file with Xerces-C_2_5_0 ,DOM taianmhzy XML 0 May 27th, 2004 04:14 AM
XML DOM with JScript --- PLEASE HELP!!! bebe XML 4 October 1st, 2003 11:40 AM
Problem writing xml file using DOM Bala XML 0 September 6th, 2003 02:15 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.