Help in XPath expression

Posted by Ashish Gupta on Stack Overflow See other posts from Stack Overflow or by Ashish Gupta
Published on 2010-03-17T13:23:34Z Indexed on 2010/03/17 13:51 UTC
Read the original article Hit count: 399

Filed under:

I have an XML document which contains nodes like following:-

<a class="custom">test</a>
<a class="xyz"></a>

I was tryng to get the nodes for which class is NOT "Custom" and I wrote an expression like following:-

XmlNodeList nodeList = document.SelectNodes("//*[self::A[@class!='custom'] or self::a[@class!='custom']]"); 

Now, I want to get IMG tags as well and I want to add the following experession as well to the above expression:-

//*[self::IMG or self::img]

...so that I get all the IMG nodes as well and any tag other than having "custom" as value in the class attribute.

Any help will be appreciated.

EDIT :- I tried the following and this is an invalid syntax as this returns a boolean and not any nodelist:-

 XmlNodeList nodeList = document.SelectNodes("//*[self::A[@class!='custom'] or self::a[@class!='custom']] && [self::IMG or self::img]"); 

© Stack Overflow or respective owner

Related posts about xpath