Multiple negation condition with SelectNodes

Topics: Developer Forum, Project Management Forum, User Forum
Jan 28, 2013 at 12:56 PM

Hi ,

I have an application where i want to check if any node is present apart from the specified nodes("list","link","a","img","div","p","span","textflow","br"), Can you please suggest how to write this as a single xpath condition.



some think like 
NewXmlDoc.DocumentNode.SelectNodes("//[not(p | div | span )]") 

Jan 28, 2013 at 1:15 PM

Hi ,

I got the solution by trial and error, thought of sharing it in the forum.


            NewXmlDoc.DocumentNode.SelectNodes("//*[not(self::p | self::div | self::span | self::a | self::link | self::list | self::li | self::textflow | self::br | self::img )]");


Eg:   NewXmlDoc.DocumentNode.SelectNodes("//*[not(self::p  | self::img )]");

 will give all the nodes other than p and img.