public string getContent(string webAddress)
    {
        HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
        HtmlDocument doc = web.Load(webAddress);
        return string.Join(" ", doc.DocumentNode.Descendants().Select(x => x.InnerText));
    }

Am using this function trying to check what does the function do! But am getting the exception which tells me the function Decendants does not exist in the current context! Though i have included the refrenced dll of agility pack!

Recommended Answers

Works here, you have the latest version?

Jump to Post

This is the code I'm using, and no issues

using System;
using System.Linq;
using HtmlAgilityPack;

namespace Testing {
    class Program {
        static void Main(string[] args) {
            HtmlWeb web = new HtmlWeb();
            HtmlDocument doc = web.Load("
Jump to Post

All 5 Replies

Works here, you have the latest version?

anything you think might be missing sir??

trying to use it in a console based c# application! included the dll of agility pack from HtmlAgilityPack.1.4.6 package's Net45 folder's dll!

This is the code I'm using, and no issues

using System;
using System.Linq;
using HtmlAgilityPack;

namespace Testing {
    class Program {
        static void Main(string[] args) {
            HtmlWeb web = new HtmlWeb();
            HtmlDocument doc = web.Load("http://www.google.com");
            Console.WriteLine(string.Join(" ", doc.DocumentNode.Descendants().Select(x => x.InnerText)));
            Console.ReadLine();

         }
    }
}

I also added the reference by using the "manage nuget" option when you right click references.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.