locked
XML DOM using JavaScript RRS feed

  • Question

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

    Wednesday, September 20, 2006 2:04 PM

All replies

  • 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

    Wednesday, September 20, 2006 4:31 PM
  • 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....

    Friday, September 22, 2006 7:36 AM
  • 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).

    Friday, September 29, 2006 2:06 AM
  • 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
    Tuesday, October 24, 2006 3:59 PM