Shoutbox

Update XML - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Update XML (/showthread.php?tid=68035)

Update XML by SnuZZer on 11-04-2006 at 09:42 AM

Hi.
Yes, it's me again!

I hope you understand :-$

I have made a script which i want to update a XML file, not add a new post, but update a post.
I have to ideas how to do that, I could clear the XML file and add the informations again, or I can update a post with a function.
But my problem is.. I don't know how to do that :-$

Here is my code.

code:
    var Sti = MsgPlus.ScriptFilesPath + "\\upload.xml";

    var xml = new ActiveXObject("Microsoft.XMLDOM");
    xml.load(Sti);
    var opdaterXML = xml.createElement("Status");
    opdaterXML.appendChild(xml.createTextNode(Status));
    xml.getElementsByTagName("Skift")[0].appendChild(opdaterXML);
    xml.save(Sti);

RE: Update XML by Matti on 11-04-2006 at 10:04 AM

In theory, this should work:

code:
var xmlFile = MsgPlus.ScriptFilesPath + "\\upload.xml";

var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.load(xmlFile);
var xmlNode = xml.documentElement.selectSingleNode("Status");
xmlNode.text = Status;
xml.save(xmlFile);
;)

I changed the variable names to something I can understand, you can change them back if you want.
RE: Update XML by SnuZZer on 11-04-2006 at 10:20 AM

Hi.
Oh, cool! It works!!
Many thanks!


RE: Update XML by Matti on 11-04-2006 at 11:18 AM

You're welcome. :)

For a full reference about the methods, properties and events of the XMLDOM, take a look at the DevGuru page. ;)