PDA

View Full Version : Write to xml and save, js/local


Fly Swatter
05-07-2003, 08:10 AM
I trying to store a playlist in a xml file locally without using IIS.
Im guessing it similar to writing to a text file, but not sure.
A simple load rewrite and save technique is good enough,

I'd also be open to useing C(+) it edit, and display the data.

Thanks!

liorean
05-07-2003, 12:45 PM
Do you mean using JScript and Windows Scripting Host for doing it? You can do it through ActiveX objects. Have a look at <http://msdn.microsoft.com/scripting/>, it contains has the references you need.

Skyzyx
05-07-2003, 03:40 PM
Check out this thread:
http://www.codingforums.com/showthread.php?s=&threadid=17144

Fly Swatter
05-07-2003, 07:30 PM
Thanks guys, that was what I needed!

Do you mean using JScript and Windows Scripting Host for doing it?

Embedding JScript into a Windows Applications would be better for this, however Im a bit of a newbie at such things. Maybe after some reading ;)

The FileSystemObject is the same as writing to a text file (using javascript). (Heres a good link: http://www.webreference.com/js/column71/index.html) so for now atleast I'll be generic.

Fly Swatter
05-09-2003, 06:37 AM
Security warnings - permission denied

Im guessing theres no "good" way to load and save a xml file using javascript.

swmr
05-09-2003, 04:17 PM
I've never been able to find any useful information for bypassing that "permission denied" error. I have only seen it with the xml save method, which is attempted in this article's (http://www.15seconds.com/issue/011113.htm) example, but it doesn't work & there's no hint of how to use it properly.

As far as activeX security-warnings go, the two ways I know of to eliminate them are either to use an .hta (http://www.vbwm.com/articles/2002/abarfield/hta01/) , or change the settings of your " local security zone (http://innovations.madmatt.net/hosting/ntfs/tutorials/activedesktop.php) " ... so if you are coding for the WSH, either of those options should work.

Fly Swatter
05-09-2003, 08:26 PM
Thanks swmr you just opened up a whole new world I didn't know existed :)

I didn't spend much time on the first link, and messing with the security setting isn't much of an option,

But the HTA passed its initial test (load/save) with fling colors, it seems ideal.

I'll put it to the test soon as I find a little time.

Thanks again!!

swmr
04-22-2004, 06:24 PM
Just thought to add this test/demo here for anyone looking...

<html>
<head>
<title>xmlSave (HTA)</title>

<?XML:NAMESPACE PREFIX = HTA />
<HTA:APPLICATION />

<script type="text/JScript">

function persistXML(){

with(dataIsland){

if(xml && src){

var xDOM = new ActiveXObject("Msxml2.DOMDocument.4.0");

xDOM.loadXML(xml);

xDOM.save(src);}
}
}
</script>

</head>
<body>

<XML id="dataIsland" src="myFile.xml" />

<input datasrc="#dataIsland" datafld="dataNode">

<button onclick="persistXML()">Save</button>

</body>
</html>


& the complex code to save as "myFile.xml" :p

<?xml version="1.0"?>
<rootNode>
<dataNode>data...</dataNode>
</rootNode>

Alex Vincent
04-22-2004, 10:18 PM
Three comments, not sure how relevant they are.

(1) DOM 3 Load and Save is a W3C Recommendation, which I believe covers file access. The target for Mozilla's implementation is 1.8a.

(2) The JSLib package from Mozdev does allow an application to access the filesystem for saving files, if the application is a Mozilla chrome app.

(3) XMLHttpRequest can read files easily.

yecril71pl
11-12-2007, 11:11 PM
I confirm that the code that saves the ActiveX object works. However, if I try to do the same thing with an XML element embedded in the HTA, I get "Permission denied" again.