XML DOM using JavaScript

Hi everybody how r u?

Actually i am really in big trouble for very small problem i guess.

I am manipulating a xml file using xml dom using javascript, after manipulating the dom tree internally, when i tried to save the file i am getting "permission denied" error. I have tried saving file locally as well remotely.

since my code is little big, i am giving u a dummy example.

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

var str = "<Root></Root>";

xmlDoc1.loadXML(str);

var path = "C:\\1.xml";

xmlDoc1.save(path);

for this also i am getting error.

Thanks a lot.

[974 byte] By [Digamber] at [2008-2-22]
# 1

Hi Digamber,

MSXML's security scheme is based on Internet Explorer's security zone settings. You will get this message if you are trying to access data in a more trusted zone from a less trusted zone.

For a complete description of what happens when your script tries to access data across zones / protocols please refer to - http://windowssdk.msdn.microsoft.com/en-us/library/ms762300.aspx

Thanks
Kaushik

KaushiS at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Web Development...
# 2

HI, tried what u said, but the problem is still there......

I am using this solution for one of problem where i have to actually giving functionlity of swaping rows of table by user hitting a button like moveUp or MoveDown.

Can i accomplish this using HTML dom or any solution....

Digamber at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Web Development...
# 3

Hi Dig.

first of all, i've encountered a similar problem in the past, and the only file-type that didn't cause errors was text, (regardless of what file-extension i used in the 'SavaAs' file-name).

it's possible your DOM object is viewed as 'object' and needs to be converted to text

you can try writing the xml into an iframe and then use:

<iFrameID>.document.execCommand('SaveAs', false, '[<path>/]<fileName>');

(as text/html type it shouldn't create security issues with javascript or the browser)

maybe i'm misreading your needs here, but if you are trying to reshape a web page using client side script why do you need to save the file? and if it's not a web-page you're attempting to manipulate, why use JavaScript?

anyway - if all you need is to swap rows in a 2D-table on a web page - another possible solution would be to swap the contents between table rows instead of rearranging them, i.e. - swapping whole rows' innerHTML, (primitive, but effective).

MosisL. at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Web Development...
# 4
Hi Dig,
I came across this problem quite a lot and I identified that it was a security setting that Service Pack 2 applies to prevent scripting across domains.
The only way I found to fix it was to right-click the file & select Unblock from the Security area of the General tab displayed.
Hope this helps.
M
mhunt13 at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Web Development...