Shoutbox

[?] Using XML DOM "childNodes" property... - 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: [?] Using XML DOM "childNodes" property... (/showthread.php?tid=95114)

[?] Using XML DOM "childNodes" property... by whiz on 07-25-2010 at 11:37 AM

I'm trying to use Node.childNodes (as opposed to enumerating Node.selectNodes(), so that I can access comments in interfaces, as well as windows, controls and elements.

...except that I don't know how to loop through one.  :S

Javascript code:
XMLO = new ActiveXObject("Microsoft.XMLDom"); // defined globally
if (XMLO.load(MsgPlus.ScriptFilesPath + "\\File.xml")) // load a file
{
    var WindowEnum = new Enumerator(XMLO.selectNodes("//Interfaces/Window"));
    for (; !WindowEnum.atEnd(); WindowEnum.moveNext()) // loop through each window in the file
    {
        var WindowId = WindowNode.getAttribute("Id");
        var WindowXMLPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/";
        // process window size, position etc.
        var ControlEnum = XMLO.selectSingleNode(WindowXMLPath + "Controls").childNodes;
         // error: object required (-2146827864)
    }
}


Following instructions here: http://www.devguru.com/technologies/xmldom/quickr...de_childNodes.html
RE: [?] Using XML DOM "childNodes" property... by foaly on 07-25-2010 at 11:44 AM

quote:
Originally posted by whiz
Javascript code:
var ControlEnum = XMLO.selectSingleNode(WindowXMLPath + "Controls").childNodes;


just guessing here, but shouldn't there be slashes after WindowXMLPath ?
RE: [?] Using XML DOM "childNodes" property... by whiz on 07-25-2010 at 12:11 PM

The slashes are in the path variable.

Javascript code:
var WindowXMLPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/";
                                                          // here ^


RE: [?] Using XML DOM "childNodes" property... by Eljay on 07-25-2010 at 02:50 PM

Are you sure the window actually has a "Controls" node? It seems to work fine here...

As for how to loop through them, you simply create an Enumerator like you have already done for the Windows.

JScript code:
var ControlEnum = new Enumerator(node.childNodes);
for(; !ControlEnum.atEnd(); ControlEnum.moveNext()) {
    ...
}


RE: [?] Using XML DOM "childNodes" property... by whiz on 07-25-2010 at 03:06 PM

Okay, I think I've got it working now.  :)