473,395 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 1208
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Eshrath | last post by:
Hi, I have an xsl where a particular child node (<sub1> and <sub2> )can occur in two type of parent nodes (<A> and <B>). like <A> <sub1>11</sub1> <sub2>22</sub2>
3
by: Mike Kamermans | last post by:
How do I find out from which tag I called a javascript function at runtime? I have a stack of nested custom tags, in the following structure: <tag_1 value="someval"> <tag_2>content</tag_2>...
2
by: Raed Sawalha | last post by:
I have following XML: How can I find the depth of XML? in other word max level of the XML <Root> ----- level 0 <Name>----- level 1 <FirstName>name</FirstName> ---- level 2...
3
by: Jack Addington | last post by:
Is there a quick and easy way in Visual Studio 2003 to get the method declaration from the ancestor so I can override/extend it? I know that if I am in another method or the constructor and type...
11
by: John Bailo | last post by:
Is anyone familar with the correct syntax for using ancestor:: ? I am trying to use it in a c# application, and I am also testing it in a parser application called Cooktop (...
3
by: webwesen | last post by:
hello, an xsl virgin here... please be gentle... got the following xml (PMD output): ================================ <file name="abc.java"> <violation line="108"> Avoid unnecessary return...
5
by: jm.suresh | last post by:
Hi I have three objects, all of them are instances of classes derived from a base class. Now, given one of the instance, I want to find the closest relative of the other two. How can I do this? ...
5
by: gnewsgroup | last post by:
In my user control, I would like to find a Label control in the parent page (the page that uses my user control). I need to update that Label.Text when something happens in the user control. I...
2
by: jamil | last post by:
Take a look at the following XML doc: <main> <a> <element>123</element> </a> <b> <element>abc</element> </b> <c>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.