Save XML file to local system

 
Off course, this operation need user’s permission, but when I using xml_dom_obj.save(), nothing happened, even a permission requesting dialog.
I donot know if it was blocked by my IE browser or the save method just can not work at the client side.
so I found another way to do this.
use FileSystemObject to save my xml file, and use Element.xml property to get my xml content.
Because of FileSystemObject.CreateTextFile() just support two charset (ASCII, Unicode), so your xml files will be limited in the 2 encodings.
 
 1
 2 <script type="text/javascript">
 3
 4 function verify()
 5 { 
 6     if (xmlDoc.readyState != 4)
 7     { 
 8         return false;
 9     }
10 }
11
12 var browserok=window.ActiveXObject
13 if (browserok)
14 var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
15 xmlDoc.async="false";
16 xmlDoc.onreadystatechange=verify;
17 xmlDoc.load('hello.xml');
18 // Gets a reference to the root node of the document.
19 root_node=xmlDoc.documentElement;
20
21 var fso = new ActiveXObject("Scripting.FileSystemObject")
22
23 // object.CreateTextFile(filename[, overwrite[, unicode]])
24 // 3rd param
25 // The value is true if the file is created as a Unicode file,
26 // false if it's created as an ASCII file
27 var tf = fso.CreateTextFile("output.xml", true, true);
28
29 tf.WriteLine("<?xml version=/"1.0/" encoding=/"UTF-16/"?>")
30 tf.write(root_node.xml)
31 tf.close()
32
33 alert("ok")
34
35 </script>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值