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>
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>