Seemingly this should be a valid XPath select for a <cue> or <par> -- why does it's inclusion cause iHDSim to report an "Unknown Exception"
//div[@id=$chapter]/button[1]
This should identify a specific <div> (using an XPathVariable set in script), and get the first button it contains. In fact it seems that the bracketed subscript notation doesn't work at all...

XPath - selecting an element by index
WoFe
el.state.focused='true'; el.state.unsetProperty('focused');
...sounds like a winner, since using the markup engine here was a workaround. Alternately, using the XPath contains() function to simulate an intersection might absolve the need for script poking the focus around altogether.
LeoXue
Is this a case where buttons under different divs share ids Otherwise I don't see why you need to handle div selection in the script. Right
nsharma
Good info Peter.
mvermef
One example where one might "resort" to setting focus through script If choosing which element to set the focus on is too complicated or inefficient to express using iHD XPaths...
TCSC
And just to clear that up :-) if all you want is the 42nd item in a nodeset, you could use:
//div[position()=42]
where 'position' is a built-in XPath function.
But that won't solve the original problem which was using trying to do queries on child nodesets.
rix_rix
Your solution sounds feasible.
One note regarding script focus management that Peter has probably already hit on but I'll reiterate: if you set focus from script using the Animated Property API (e.g. document.someElementId.state.focused = "true";), script will take control of focus management and lock it up. However, you can immediately release control back to markup by doing document.someElementId.state.unsetProperty("focused"); The unsetProperty() will give control back to the markup engine, but the focused element will remain as the script set it (it will not revert as a style property would).
Szymon Kosok
The reason it's important for markup to handle this (in this case) and not script is that I'm trying to set the focus in a way that doesn't break the explicit/implicit navigation engine. As I had been observing (and Peter confirmed that this is a feature -- not something I was doing wrong -- in another message), the moment that .focused is set from script, the assumption is that script is taking over focus management entirely and the markup navigation scheme is blocked.
Serapth
Alexnaldo Santos
The subset of XPath specified by HD DVD doesn't allow querying for child or parent nodes, so the bolded red part below is likely what's breaking your statement:
//div[@id=$chapter]/button[1]
I believe bracketed subscript works (so //div[1] would return the first div in the returned nodeset, for what it's worth), but the usefulness of that is limited since you cannot delve into child nodes as you are trying to.