how to find elements that don't have ancestor

K

kishjeff

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
 
K

kishjeff

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.
 
P

Peyo

kishjeff a écrit :
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.
 
K

kishjeff

kishjeff a écrit :
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
 
P

Peyo

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.
 
P

Peter Flynn

kishjeff said:
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
 
J

Jeff Kish

kishjeff said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top