What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Load XML

Load XML
Author: Message:
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. Load XML
Hi.
I'm trying to get information from a XML document, but my script doesn't work.
Here is my code:

code:
36: var xml = new ActiveXObject( "Microsoft.XMLDOM" );
37:
38: var xmlOpdaterFil = MsgPlus.ScriptFilesPath + "\\kanal.xml";
39: xml.load(xmlOpdaterFil);
40:     
41: var hentKanal = xml.selectNodes("/Item/Kanal");
42:
43: kanal = hentKanal[1].text;

I have tried to translate the error from danish to english:
code:
Function called: OnEvent_Uninitialize
The script is stopped
The script is starting
The script is started and ready
Function called: OnEvent_Initialize
Error: An object is obligatory (code: -2146827864)
       File: TV Guide.js. Line: 43.
Function OnEvent_Initialize gave an error. Code: -2147352567

Anyone who knows why it doesn't work?

Thanks in advance.

This post was edited on 09-09-2007 at 07:02 PM by SnuZZer.
09-09-2007 04:50 PM
Profile E-Mail PM Web Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: Load XML
code:
43: kanal = xml.hentKanal[1].text;

maybe that?

This post was edited on 09-09-2007 at 08:45 PM by NanaFreak.
09-09-2007 08:44 PM
Profile PM Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: Load XML
quote:
Originally posted by NanaFreak
code:
43: kanal = xml.hentKanal[1].text;

maybe that?

41: var hentKanal = xml.selectNodes("/Item/Kanal");
42:
43: kanal = hentKanal[1].text;
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
09-09-2007 09:29 PM
Profile PM Web Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: Load XML
It looks like the selectNodes call isn't returning any nodes.
09-09-2007 09:43 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Load XML
Select Nodes returns an Array of the nodes.

code:
36: var xml = new ActiveXObject( "Microsoft.XMLDOM" );
37:
38: var xmlOpdaterFil = MsgPlus.ScriptFilesPath + "\\kanal.xml";
39: xml.load(xmlOpdaterFil);
40:
41: var hentKanal = xml.selectNodes("/Item/Kanal");
42:
43: for (var i=0; i<hentKanal.length; i++) {
44:     Debug.Trace(hentKanal[i]);
45: }

This post was edited on 09-10-2007 at 12:02 AM by matty.
09-10-2007 12:01 AM
Profile E-Mail PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Load XML
When I use the code Matty have posted it says:

code:
Function called: OnEvent_Uninitialize
Script has been stopped
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
Error: Types doesn't match (code: -2146828275)
       File: TV Guide.js. Line: 45.
Function OnEvent_Initialize returned an error. Code: -2147352567

But actually it's only one thing in the XML, I need, I just thought it was easier to make it as an array and then choose number one in the array, but it must be possible just to choose one "node"?

This is my XML:
code:
<?xml version="1.0" encoding="UTF-16"?>
<Item>
    <Kanal>1</Kanal>
</Item>
09-10-2007 04:37 AM
Profile E-Mail PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Load XML
quote:
Originally posted by SnuZZer
But actually it's only one thing in the XML, I need, I just thought it was easier to make it as an array and then choose number one in the array, but it must be possible just to choose one "node"?
Arrays are 0 based so they start at 0, not 1, so 1 really = 2 in the array index
[Image: dt2.0v2.png]      Happy Birthday, WDZ
09-10-2007 04:41 AM
Profile PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Load XML
Hi.
Oh, thanks -dt-!
It's so embarrassing I forgot that!

So, here is the final script:

code:
    var xmlOpdaterFil = MsgPlus.ScriptFilesPath + "\\kanal.xml";
    xml.load(xmlOpdaterFil);

    var xml = new ActiveXObject( "Microsoft.XMLDOM" );

    var xmlOpdaterFil = MsgPlus.ScriptFilesPath + "\\kanal.xml";
    xml.load(xmlOpdaterFil);

    var hentKanal = xml.selectNodes("/Item/Kanal");

    kanal = hentKanal[0].text;

Thanks to everybody for helping! (L)

This post was edited on 09-10-2007 at 01:17 PM by SnuZZer.
09-10-2007 01:16 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On