Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 20:42

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C# Using HtmlAgilityPack

Discussion on C# Using HtmlAgilityPack within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
badguy4you's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 477
Received Thanks: 178
C# Using HtmlAgilityPack

Hi guys i am facing an annoing problem please i wanna to have your help with it

i have the following html

Code:
<div class="sideInfo">
<a class="getLink" href="info">
<span class="wrap">NEW</span>
</a>
<img class="nation" src="img/xyz.png" alt="NEW">
</div>
i am trying

Code:
var Value = GET.DocumentNode.SelectSingleNode("//a[@class='getLink']").Attributes["href"].Value;
to get the href value but i always get an error and cant get it so please help me to know what is going on

ERROR LOG :
Object reference not set to an instance of an object.
badguy4you is offline  
Old 07/18/2012, 16:48   #2

 
boxxiebabee's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
Code:
string html =
                "<div class='sideInfo'><a class='getLink' href='info'><span class='wrap'>NEW</span></a><img class='nation' src='img/xyz.png' alt='NEW'></div>";
            var doc = new HtmlDocument { OptionFixNestedTags = true };
            doc.LoadHtml(html);
            HtmlNode node = doc.DocumentNode.SelectSingleNode("//a[@class='getLink']");
            string href = node != null ? node.Attributes["href"].Value : null;
boxxiebabee is offline  

Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.