Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7159129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:10:46+00:00 2026-05-28T13:10:46+00:00

I am using the HtmlAgilityPack to retrieve information from a web page and, at

  • 0

I am using the HtmlAgilityPack to retrieve information from a web page and, at present, am using it to show values on the page itself using a ListView control in a button click method.

 protected void Button1_Click(object sender, EventArgs e)
 {
     string url = TextBox1.Text.ToString();
     var webGet = new HtmlWeb();
     var document = webGet.Load(url);
     // Below code crawl the data and store in generic IEnumerable<T> fashion //
     var TheWeb = 
           from info in document.DocumentNode.SelectNodes("//div[@class='article-listing']//div[@class='media-data']")
           from link in info.SelectNodes("h4//a").Where(x => x.Attributes.Contains("href"))
           from content in info.SelectNodes("p").Where(y => y.HasAttributes != true)
           from author in info.SelectNodes("p[@class='article-meta']//a[@rel='author']").Where(z => z.Attributes.Contains("href"))
           from date in info.SelectNodes("p[@class='article-meta']//span")
           select new
           {
                 LinkURL = link.Attributes["href"].Value,
                 Text = content.InnerText,
                 Author = author.InnerText,
                 Date = date.InnerText
           };
     lvLinks.DataSource = TheWeb;
     lvLinks.DataBind(); 
}

But now I want to store the data in SQL Server and want to run the code using some function (instead of button click).

For that I want to store the data in some other form instead of an IEnumerable<> style which uses LINQ to extract values.

Please suggest.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:10:46+00:00Added an answer on May 28, 2026 at 1:10 pm

    You can have a custom class with the structure

    public class ParseData
    {
        public string LinkURL { get; set; }
        public string Text { get; set; } 
        public string Author { get; set; }
        public string Date { get; set; }
    }
    

    Populate it with your query

    var TheWeb = 
           from info in document.DocumentNode.SelectNodes("//div[@class='article-listing']//div[@class='media-data']")
           from link in info.SelectNodes("h4//a").Where(x => x.Attributes.Contains("href"))
           from content in info.SelectNodes("p").Where(y => y.HasAttributes != true)
           from author in info.SelectNodes("p[@class='article-meta']//a[@rel='author']").Where(z => z.Attributes.Contains("href"))
           from date in info.SelectNodes("p[@class='article-meta']//span")
           select new ParseData
           {
                 LinkURL = link.Attributes["href"].Value,
                 Text = content.InnerText,
                 Author = author.InnerText,
                 Date = date.InnerText
           };
    var parseData = TheWeb.ToList();
    

    And now using System.Xml.Serialization.XmlSerializer serialize this data in XML. Store this XML in your DB and retrieve when ever required.

    Tutorial explaining how to Serialize object in XML and Deserialize back to object.

    Hope this works for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am using HtmlAgilityPack to scrap some data from web using c# .
I currently have 2 JavaScript variables in which I need to retrieve values from.
I'm using HtmlAgilityPack. I hover over the parent node and its ChildNodes show several
I'm using HtmlAgilityPack and I'd like to select the value from inside the td
I'm trying to extract text from HTML using HtmlAgilityPack. I successfully added HtmlAgilityPack to
With using HtmlAgilityPack and c# 4.0 how can you determine whether page is being
I have been using HTMLAgilityPack from within Visual Studio without a single problem. I
I am using HTMLAgilityPack with my C# winform application. I loaded HTMLAgilityPack from my
I have to gather information from a product page which does not have any
I am using HtmlAgilityPack. I create an HtmlDocument and LoadHtml with the following string:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.