views:

29

answers:

1

Hello, I have built a Vista Gadget. It grabs a local XMl file called "settings.xml". It loads it and I change a few things. then I call the xmldoc.Save("settings.xml") method which works fine of you run it in Internet Explorer... but if you run it in the sidebar it does not write to the xml - only loads from.

how do I get it to write to the xml file?

        settingsxmldoc = new ActiveXObject("Microsoft.XMLDOM");
        settingsxmldoc.async = false;
        settingsxmldoc.onreadystatechange = readSettingsXML;
        settingsxmldoc.load("settings.xml");

        if (Favorites.length > 0)
        {
            for (i = 0; i < Favorites.length; i++)
            {
                var newElement = settingsxmldoc.createElement("db");
                newElement.appendChild(settingsxmldoc.createTextNode(Favorites[i]));
                favdbs[0].appendChild(newElement);
            }
        }

        settingsxmldoc.save("settings.xml");

Thanks!

+1  A: 

Within a gadget, a partially qualified file name evaluates to the x-gadget:/// protocol. ActiveXObjects don't know anything about this protocol, so they don't know where to put the file and they throw an error. Use a fully qualified file name and it should work fine:

settingsxmldoc.save(System.Gadget.path + "\\settings.xml");
Andy E