View Single Post
  #1 (permalink)  
Old July 27th, 2009, 07:29 PM
baseliner baseliner is offline
Authorized User
Points: 102, Level: 2
Points: 102, Level: 2 Points: 102, Level: 2 Points: 102, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Posts: 23
Thanks: 5
Thanked 0 Times in 0 Posts
Default Excluding elements in XPath

I'm trying to exclude certain elements using XPath within an ASP.NET C# application. My XML structure is as follows:

Code:
<A>
  <B>
     <C>
       <D>
       <D>
What I want is the following:
Code:
<A>
  <B>
     <C>
       <D>
where the only <D> element left meets a certain criterion. I've been looking online and experimenting for some time now but not able to figure this out. So as a precursor, I'm trying to just exclude all <D> elements in the document with the following XPath code string that goes into the SelectNodes method in my .NET app:

"(//*)[not(self::D)]"

This doesn't work. Not sure what's the right way to do this (and I'm hoping I can do this with just XPath and not XSLT to minimize overhead in loading a stylesheet file) .. thanks!

Last edited by baseliner; July 27th, 2009 at 08:38 PM.
Reply With Quote