HtmlAgilityPack SelectNodes expression to ignore an element with a certain attribute

Posted by thaky on Stack Overflow See other posts from Stack Overflow or by thaky
Published on 2012-11-05T03:07:38Z Indexed on 2012/11/06 23:01 UTC
Read the original article Hit count: 560

I am trying to select nodes except from script nodes and a ul that has a class called 'relativeNav'. Can someone please direct me to the right path? I have been searching for this for a week and I can't find it anywhere. Currently I have this but it obviously selecting the //ul[@class='relativeNav'] as well. Is there anyway to put an NOT expression of it so that SelectNode will ignore that one?

        foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//body//*[not(self::script)]/text()"))
        {
            Console.WriteLine("Node: " + node);
            singleString += node.InnerText.Trim() + "\n";
        }

© Stack Overflow or respective owner

Related posts about c#

Related posts about xpath