开发者

Vista Gadget - Write to a XML file

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 writ开发者_如何学编程e 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");


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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜