On Feb 6, 1:38 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> I'm trying to migrate from jQuery 1.1.3 to 1.2.2, and I'm having trouble
> converting my XPath expressions.  In CSS, asterisks are "deep", i.e. they
> match all elements that are descendants of the context node.  In XPath,
> they are not, i.e. they match only the elements that are _direct_
> descendants of the context node.
>
> Consider this XML:
>
> <unknown_node_name>
>   <KNOWN_NODE>right node</KNOWN_NODE>
>   <more_unknown_deepiness>
>     <KNOWN_NODE>wrong node</KNOWN_NODE>
>   </more_unknown_deepiness>
> </unknown_node_name>
>
> Now, to get the "right node", I would use the XPath expression
> "/*/KNOWN_NODE".  (Note that the node name has to be uppercase for some
> reason, or jQuery 1.1.3 won't find anything at all.)
>
> I don't see any way to do this with CSS selectors.  The Basic XPath plugin
> translates the XPath expression to "* > KNOWN_NODE", which returns both
> the right node _and_ the wrong node.
>
> Anyone have a clue as to what I should do?
>
> Tim

The CSS 3 :root selector is not supported unfortunately, but the root
node of a document is represented by document.documentElement.

So you could try:

$('> KNOWN_NODE', document.documentElement)

or

$(document.documentElement.tagName + ' > KNOWN_NODE')

Does that work?


--Klaus



Reply via email to