Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XPath - Limiting Parent

Reply
Thread Tools

XPath - Limiting Parent

 
 
Michael Doyle
Guest
Posts: n/a
 
      01-09-2006
Hi,

Using XPath, I want to get all elements FOO which are not children of
BAR.

What i have done in this instance is:
//FOO[name(..)!='BAR']

this only works when BAR is immediately below FOO, it's also kinda
ugly.
Is there a better way?

Thanks,
Micky

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-09-2006


Michael Doyle wrote:

> Using XPath, I want to get all elements FOO which are not children of
> BAR.
>
> What i have done in this instance is:
> //FOO[name(..)!='BAR']


You do not need name checks, you can simply do
//FOO[not(parent::BAR)]

> this only works when BAR is immediately below FOO,


That is what you want if your description above is correct: FOO elements
which are not children of BAR.
If you want FOO elements which are not descendants of BAR then you can use
//FOO[not(ancestor::BAR)]

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
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
If a class Child inherits from Parent, how to implementChild.some_method if Parent.some_method() returns Parent instance ? metal Python 8 10-30-2009 10:31 AM
6500: User-Based Rate Limiting AND Total Rate Limiting Patrick Cervicek Cisco 0 08-07-2007 03:07 PM
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57