简体   繁体   中英

How to get the Link or InnerText using HTMLAgilityPack

I have this structure:

<p class="info">Sample:
    <strong>
       <a href="http://PleaseGetMe.com"target="_blank">http://PleaseGetMe.com</a>
    </strong> 
</p>

What I want is to get the http://PleaseGetMe.com

Here is what I'm trying:

                var a = doc.SelectNodes("//*[@class='info']//a");
                Console.WriteLine(a);

Which is not successful.

Here is my Implementation

foreach (HtmlNode node in doc.SelectNodes("//*[@class='info']//a"))
                {
                    string value = node.InnerText;
                    Console.WriteLine(value);
                }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM