468,103 Members | 1,393 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,103 developers. It's quick & easy.

how to find elements that don't have ancestor

Hi.

Can someone tell me how to find all the elements of type 'table' which
have an attribute named 'source' and are not descendents of
'querybox' ?

I'm sort of wrestling with it and am hoping someone can tell me if it
is possible.

I know it is possible to find all elements that ARE descendents of
'querybox' that have a given attribute and are of a certain type.

Jeff
Oct 10 '08 #1
6 1078
On Oct 10, 2:17*pm, kishjeff <jk...@us.ibm.comwrote:
Hi.

Can someone tell me how to find all the elements of type 'table' which
have an attribute named 'source' and are not descendents of
'querybox' ?

I'm sort of wrestling with it and am hoping someone can tell me if it
is possible.

I know it is possible to find all elements that ARE descendents of
'querybox' that have a given attribute and are of a certain type.

Jeff
oh geez, I'm trying out xpath. sorry.. I forgot to mention that
insignificant item.
Oct 10 '08 #2
kishjeff a écrit :
>Can someone tell me how to find all the elements of type 'table' which
have an attribute named 'source' and are not descendents of
'querybox' ?
oh geez, I'm trying out xpath. sorry.. I forgot to mention that
insignificant item.
Why not :
//table[@source and (count(ancestor::querybox) = 0)]

Cheers,

p.
Oct 10 '08 #3
On Oct 10, 4:02*pm, Peyo <o...@est.cawrote:
kishjeff a écrit :
Can someone tell me how to find all the elements of type 'table' which
have an attribute named 'source' and are not descendents of
'querybox' ?
oh geez, I'm trying out xpath. sorry.. I forgot to mention that
insignificant item.

Why not :
//table[@source and (count(ancestor::querybox) = 0)]

Cheers,

p.
thanks so much. that works just fine evidently. is there a way of
doing it without count, say with some sort of "not
decendent::querybox" sort of thing?

regards in any case
Jeff
Oct 10 '08 #4
kishjeff a écrit :
thanks so much. that works just fine evidently.
You did most of the work ;-)

< is there a way of
doing it without count, say with some sort of "not
decendent::querybox" sort of thing?
Just try not(descendant::querybox)

not() is a *function*, hence the parentheses.

XPath 2.0 also introduces some other functions like exists().

Be aware that not(descendant::querybox) it is not what you have asked :-)

Cheers,

p.b.
Oct 11 '08 #5
kishjeff wrote:
On Oct 10, 4:02 pm, Peyo <o...@est.cawrote:
>kishjeff a écrit :
>>>Can someone tell me how to find all the elements of type 'table' which
have an attribute named 'source' and are not descendents of
'querybox' ?
oh geez, I'm trying out xpath. sorry.. I forgot to mention that
insignificant item.
Why not :
//table[@source and (count(ancestor::querybox) = 0)]

Cheers,

p.

thanks so much. that works just fine evidently. is there a way of
doing it without count, say with some sort of "not
decendent::querybox" sort of thing?

regards in any case
Jeff
//table[@source and not(ancestor::querybox)]

///Peter
Oct 11 '08 #6
On Sat, 11 Oct 2008 14:31:08 +0100, Peter Flynn
<pe********@m.silmaril.iewrote:
>kishjeff wrote:
>On Oct 10, 4:02 pm, Peyo <o...@est.cawrote:
>>kishjeff a écrit :

Can someone tell me how to find all the elements of type 'table' which
have an attribute named 'source' and are not descendents of
'querybox' ?
oh geez, I'm trying out xpath. sorry.. I forgot to mention that
insignificant item.
Why not :
//table[@source and (count(ancestor::querybox) = 0)]

Cheers,

p.

thanks so much. that works just fine evidently. is there a way of
doing it without count, say with some sort of "not
decendent::querybox" sort of thing?

regards in any case
Jeff

//table[@source and not(ancestor::querybox)]

///Peter
ah its so easy... thanks.
Oct 12 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Raed Sawalha | last post: by
11 posts views Thread by John Bailo | last post: by
3 posts views Thread by webwesen | last post: by
5 posts views Thread by jm.suresh | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.