quote:
Originally posted by whiz
Ok, let's see.
js code:
var ControlsXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/Controls/Control";
var ElementsXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/Elements/Element";
/
ret.Interface[WindowId] = new Object();
ret.Interface[WindowId].Controls = new Object();
ret.Interface[WindowId].Elements = new Object();
1) Am I able to create my own, like this? For example, to get the window title:
js code:
var CaptionsXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/Attributes/Caption";
var TitlesXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/TitleBar/Title/Text";
But... it can't be enumerated:
js code:
var K = new Enumerator(xml.selectNodes(CaptionsXPath));
It's different, because the value isn't "<Item Parameter="Value">", but "<Item>Value</Item>". How can I get that?
js code:
var K = new Enumerator(xml.selectNodes(ControlsXPath));
if(K.count() > 0) {
for(; !K.atEnd(); K.moveNext()) {
var ControlNode = K.item();
var ControlId = ControlNode.getAttribute("Id");
// Define an object for this control type (as in ButtonControl or StaticControl) that contains the actual control
// Only done when necessary
if(ControlId in ret.Interface[WindowId].Controls) {
//[alert the user that there's 2 or more controls with the same ID]
continue;
}
// You'll have to do your own stuff here
ret.Interface[WindowId].Controls[ControlId] = "null" //[JScript control definition stuff]
}
}
2a) If that gets a control ID, then I assume that getting the type uses the same method, replacing ".getAttribute("Id")" with ".getAttribute("xsi:type")", right?
2b) Would this work:
[code left out]
1) yes.
2) also yes, but instead of "ControlLeft" and "ControlId" variables, you may wanna use an object with these properties:
code:
var Control = new Object();
Control.Id = xmlNode.getAttribute("Id"); // xmlNode in this case is K.item();
Control.Type = xmlNode.getAttribute("xsi:type");
Control.Position = {
"Left" : xmlPosNode.getAttribute("Left"),
"Top" : xmlPosNode.getAttribute("Top"),
"Width" : xmlPosNode.getAttribute("Width"),
"Height" : xmlPosNode.getAttribute("Height") // Note that there's no comma on this one
}// Object definition, version 2
About the enumeration thingy: there's probably only one node, so enumeration would be useless with "var CaptionsXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/Caption";" and such. You can retrieve the caption using the following code:
JScript code:
var CaptionXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/Caption"
var node = xml.selectSingleNode(CaptionXPath);
var sCaption = node.text;
quote:
Originally posted by whiz
I apologise for so many questions, but this is a confusing topic for me...
Never mind, I started with the same amount of questions
Oh and sorry for the late answer. Had no PC for over a week