[HELP]weird xml problem - 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: [HELP]weird xml problem (/showthread.php?tid=88712)
[HELP]weird xml problem by DaAniv on 01-26-2009 at 03:00 PM
JavaScript code: USS=USSD.getElementsByTagName("UserSentences")[0]
JavaScript code: (line 20) var name=USS.getElementsByTagName("UserSentence")[i].childNodes[0].text;
Debug.Trace(name)
Xml code: <UserSentences>
<UserSentence><command>pipy</command><sentence>pipy</sentence></UserSentence></UserSentences>
just wrote stuff in xml check if it works
it gets the name but it still says for some reason
code: pipy
Error: Object required (code: -2146827864)
File: xml.js. Line: 20.
Error: Object required (code: -2146827864)
File: xml.js. Line: 20.
RE: [HELP]weird xml problem by matty on 01-26-2009 at 03:07 PM
Can you post the entire contents of xml.js and we will take a look at it for you.
js code: getString('C:\\test.xml', '//UserSentences/UserSentence/command');
function getString(sXmlFile, sXmlId)
try {
var xml = new ActiveXObject('Microsoft.XMLDOM');
} catch(e) {
try {
var xml = new ActiveXObject('MSXML2.DOMDocument');
} catch(e) {
return false;
}
}
xml.async = true;
xml.load(sXmlFile);
Debut.Trace(xml.selectSingleNode(sXmlId).text);
}
RE: [HELP]weird xml problem by DaAniv on 01-26-2009 at 03:19 PM
JavaScript code: function OnEvent_Initialize(MessengerStart)
{
xml=new ActiveXObject("Microsoft.XMLDOM");
xml.async=true;
xmlFile=MsgPlus.ScriptFilesPath + "\\Settings.xml";
xml.load(xmlFile);
USSD=new ActiveXObject("Microsoft.XMLDOM");
USSD.async=true;
USSFile=MsgPlus.ScriptFilesPath + "\\UserSentences.xml";
USSD.load(USSFile);
USS=USSD.getElementsByTagName("UserSentences")[0]
GetColor()
}
this is the xml.js
JavaScript code: function saveSentences(SScommand,SSentence)
{
US=USSD.createElement("UserSentence")
SC=USSD.createElement("command")
SSC=USSD.createTextNode(SScommand)
SS=USSD.createElement("sentence")
SSS=USSD.createTextNode(SSentence)
USS.appendChild(US)
US.appendChild(SC)
SC.appendChild(SSC)
US.appendChild(SS)
SS.appendChild(SSS)
USSD.save(USSFile)
}
function GetUserSentences()
{
children=USS.getElementsByTagName("UserSentence").length
for(i=0;i<=children;i++)
{
var name=USS.getElementsByTagName("UserSentence")[i].childNodes[0].text;
Debug.Trace(name)
commands+='<Command>';
commands+='<Name>'+name+'</Name>';
commands+='</Command>';
}
}
RE: [HELP]weird xml problem by DaAniv on 01-26-2009 at 04:43 PM
it also tells me when the sent message isn't a commend in the xml
code: Error: Object required (code: -2146827864)
File: Sentences.js. Line: 570.
Function OnEvent_ChatWndSendMessage returned an error. Code: -2147352567
it's in a function OnEvent_ChatWndSendMessage(ChatWnd, Message){
JavaScript code: for(i=0;i<=children;i++)
{
if(Message.toLowerCase()=="/"+USS.getElementsByTagName("UserSentence")[i].childNodes[0].text)
{
RMessage=Find(USS.getElementsByTagName("UserSentence")[i].childNodes[1].text)
break;
}
}
RE: [HELP]weird xml problem by ShawnZ on 01-26-2009 at 04:49 PM
wtf, when did the forums get syntax highlighting?!
RE: [HELP]weird xml problem by matty on 01-26-2009 at 04:54 PM
quote: Originally posted by ShawnZ
wtf, when did the forums get syntax highlighting?!
WDZ's reply to [code][/code] suggestion
RE: [HELP]weird xml problem by DaAniv on 01-26-2009 at 05:19 PM
solved it my problem I did <=children not <children
RE: [HELP]weird xml problem by matty on 01-26-2009 at 05:50 PM
quote: Originally posted by DaAniv
solved it my problem I did <=children not <children
Sorry I didn't get a chance to look over it fully to help out. The reason it is like this is because .Length isn't 0 based which means it does not start counting at 0. You can either do .length-1 or not include the = in your condition.
RE: [HELP]weird xml problem by DaAniv on 01-26-2009 at 05:53 PM
thanks anyway ^_^
|