how to find elements that don't have ancestor 
October 10th, 2008, 07:25 PM
| | | |
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 | 
October 10th, 2008, 07:35 PM
| | | | 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. | 
October 10th, 2008, 09:05 PM
| | | | 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. | 
October 11th, 2008, 12:55 AM
| | | | 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 | 
October 11th, 2008, 07:55 AM
| | | | 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. | 
October 11th, 2008, 02:35 PM
| | | | 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 | 
October 12th, 2008, 02:55 PM
| | | | 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. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|