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

XML Help needed
Author: Message:
Mothuim
New Member
*


Posts: 14
Joined: Jul 2006
O.P. XML Help needed
I've been working on my statistics script and have i've been trying to change it so that the data it collects is stored in XML rather than a text file. This has been going fine and it works perfectly if you only have one user using the script. If i signed on to WLM with another account it goes wrong.

Currently my XML looks like this:

code:
<Statistics>
    <User UserID="357135843">
        <Session>0</Session>
        <Total/>
        <SMC>0</SMC>
        <RMC>0</RMC>
    </User>
</Statistics>


And when a new User signs on it it will create some more elements like this:

code:
<Statistics>
    <User UserID="#######">
        <Session>0</Session>
        <Total>0Total/>
        <SMC>0</SMC>
        <RMC>0</RMC>
    </User>
    <User UserID="#######">
        <Session>0</Session>
        <Total>0Total/>
        <SMC>0</SMC>
        <RMC>0</RMC>
    </User>
</Statistics>


The problem comes when it tries to write the data to the file, it will still write to the first users part. I could get around this by making separate files for each user but thats not ideal.

After googling for hours i think i need to use the getelementbyid method but i try and it doesn't work!

Sadly i've been fiddling with this so long i can't remember how i got that far and now it doesn't do much and says the object doesn't support this method.

This is a snippet from my code:

code:
if (xmlDoc.getElementById(Messenger.MyUserId) == "null")
{Debug.Trace("User does not Exist")
NewUser();}
else
{Debug.Trace("User exists");}


This post was edited on 07-17-2006 at 12:22 AM by Mothuim.
07-16-2006 10:20 PM
Profile E-Mail PM Find Quote Report
Silentdragon
Full Member
***

Avatar
if(life==null && wrists) EmoAlert();

Posts: 148
Reputation: 2
34 / Male / –
Joined: Jun 2006
RE: XML Help needed
Shouldn't
code:
xmlDoc.getElementById(Messenger.MyUserId) == "null"
be
code:
xmlDoc.GetElementById(Messenger.MyUserId) == null

MSDN says jscript for GetElementById should be capitalized like that. And most things when you check for null aren't in quotes. Your checking against the string null not null itself.
07-16-2006 11:24 PM
Profile E-Mail PM Web Find Quote Report
Mothuim
New Member
*


Posts: 14
Joined: Jul 2006
O.P. RE: XML Help needed
Thanks for the reply but that isn't the problem, i still get the same error:

quote:
Function called: OnEvent_Signin
Error: Object doesn't support this property or method.
       Line: 158. Code: -2146827850.
Function OnEvent_Signin returned an error. Code: -2147352567


This is what xmlDoc is defined as btw, is it right?

code:
var xmlDoc = new ActiveXObject('Microsoft.XMLDOM');

07-16-2006 11:29 PM
Profile E-Mail PM Find Quote Report
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
RE: XML Help needed
try this:
code:
var nodeUser = xmlDoc.documentElement.selectSingleNode("User[@UserId='"+Messenger.MyUserId+"']");
if(nodeUser){
     Debug.Trace("User exists.");
} else {
     Debug.Trace("User does not exist.");
}

[Image: clb2.jpg]
07-16-2006 11:46 PM
Profile E-Mail PM Web Find Quote Report
Mothuim
New Member
*


Posts: 14
Joined: Jul 2006
O.P. RE: XML Help needed
Thanks but that wasn't right either, however it did help me to get it right.

The right code was:

code:
var nodeUser = xmlDoc.documentElement.selectSingleNode("//Statistics/User[@UserID="+Messenger.MyUserId+"]");
if(nodeUser){
     Debug.Trace("User exists.");
     
} else {
     Debug.Trace("User does not exist.");
}


This is the first half the problem, i can detect if it is a new user, now i need to make it right to the new user's tags/elements/thing (i don't really the know the correct term!).

I'll try it myself I think i have a good idea how to do it, but i may be back if i get very stuck.

Thanks

UPDATE: Second problem solved a few minutes after the first. Expect a new version soon!

This post was edited on 07-17-2006 at 12:44 AM by Mothuim.
07-17-2006 12:21 AM
Profile E-Mail PM 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