On Feb 7, 12:56 pm, [EMAIL PROTECTED] wrote:
> > 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?
>
> Yes it does, thanks!  This clears up a lot of confusion on my part even
> though it isn't the answer I was looking for.  This will only work when
> KNOWN_NODE is only one level deep, and as far as I know there is still no
> way to go n levels deep with CSS expressions.
>
> However, I now realise I can do this with the children() method:
>
> $(document.documentElement).children().find('> KNOWN_NODE')

I'm confused. You said you don't want to go n level deep. Your query
would perfectly match "wrong node" now (based on the XML snippet you
posted and assuming that the outermost unknown node is the root node).
Anyway, you could write that as:

$('> * > KNOWN_NODE', document.documentElement);

which now looks similiar to the XPATH equivalent:

$('/*/KNOWN_NODE');

I think you have messed up wrong and right in the example?


--Klaus

Reply via email to