Connecting Tech Pros Worldwide Help | Site Map

how to find elements that don't have ancestor

kishjeff
Guest
 
Posts: n/a
#1: Oct 10 '08
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
kishjeff
Guest
 
Posts: n/a
#2: Oct 10 '08

re: how to find elements that don't have ancestor


On Oct 10, 2:17*pm, kishjeff <jk...@us.ibm.comwrote:
Quote:
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.
Peyo
Guest
 
Posts: n/a
#3: Oct 10 '08

re: how to find elements that don't have ancestor


kishjeff a écrit :
Quote:
Quote:
>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' ?
Quote:
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.


kishjeff
Guest
 
Posts: n/a
#4: Oct 11 '08

re: how to find elements that don't have ancestor


On Oct 10, 4:02*pm, Peyo <o...@est.cawrote:
Quote:
kishjeff a écrit :
>
Quote:
Quote:
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
Peyo
Guest
 
Posts: n/a
#5: Oct 11 '08

re: how to find elements that don't have ancestor


kishjeff a écrit :
Quote:
thanks so much. that works just fine evidently.
You did most of the work ;-)

< is there a way of
Quote:
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.
Peter Flynn
Guest
 
Posts: n/a
#6: Oct 11 '08

re: how to find elements that don't have ancestor


kishjeff wrote:
Quote:
On Oct 10, 4:02 pm, Peyo <o...@est.cawrote:
Quote:
>kishjeff a écrit :
>>
Quote:
>>>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
Jeff Kish
Guest
 
Posts: n/a
#7: Oct 12 '08

re: how to find elements that don't have ancestor


On Sat, 11 Oct 2008 14:31:08 +0100, Peter Flynn
<peter.nosp@m.silmaril.iewrote:
Quote:
>kishjeff wrote:
Quote:
>On Oct 10, 4:02 pm, Peyo <o...@est.cawrote:
Quote:
>>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.
Closed Thread