Shoutbox

XML Help needed - 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: XML Help needed (/showthread.php?tid=63400)

XML Help needed by Mothuim on 07-16-2006 at 10:20 PM

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


RE: XML Help needed by Silentdragon on 07-16-2006 at 11:24 PM

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.
RE: XML Help needed by Mothuim on 07-16-2006 at 11:29 PM

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');


RE: XML Help needed by cooldude_i06 on 07-16-2006 at 11:46 PM

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.");
}


RE: XML Help needed by Mothuim on 07-17-2006 at 12:21 AM

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!