Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > how to find elements that don't have ancestor

Reply
Thread Tools

how to find elements that don't have ancestor

 
 
kishjeff
Guest
Posts: n/a
 
      10-10-2008
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
 
Reply With Quote
 
 
 
 
kishjeff
Guest
Posts: n/a
 
      10-10-2008
On Oct 10, 2:17*pm, kishjeff <(E-Mail Removed)> wrote:
> 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.
 
Reply With Quote
 
 
 
 
Peyo
Guest
Posts: n/a
 
      10-10-2008
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.


 
Reply With Quote
 
kishjeff
Guest
Posts: n/a
 
      10-10-2008
On Oct 10, 4:02*pm, Peyo <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
Peyo
Guest
Posts: n/a
 
      10-11-2008
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.
 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      10-11-2008
kishjeff wrote:
> On Oct 10, 4:02 pm, Peyo <(E-Mail Removed)> wrote:
>> 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
 
Reply With Quote
 
Jeff Kish
Guest
Posts: n/a
 
      10-12-2008
On Sat, 11 Oct 2008 14:31:08 +0100, Peter Flynn
<(E-Mail Removed)> wrote:

>kishjeff wrote:
>> On Oct 10, 4:02 pm, Peyo <(E-Mail Removed)> wrote:
>>> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
org.apache.jasper.JasperException: Could not find ancestor parseTag pcouas@infodev.fr Java 0 03-07-2005 07:05 PM
Why doesn't ri look into ancestor classes to find help? Ilmari Heikkinen Ruby 0 01-17-2005 12:29 AM
How to find out the Parent or the Ancestor Node. Eshrath XML 3 10-27-2004 02:47 AM



Advertisments