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 6820323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:24:40+00:00 2026-05-26T21:24:40+00:00

Is there an easy way to count the nodes in a HTML file? I

  • 0

Is there an easy way to count the nodes in a HTML file? I also need to count nodes of a certain type such as div etc.

I’d like to do this if possible without having to use an external library like HTMLAgilityPack if possible. Also, the HTML I’m dealing with is not guarenteed to be well formed and valid.

Is there a way to do this from C#?

Thanks.

  • 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-26T21:24:41+00:00Added an answer on May 26, 2026 at 9:24 pm

    first of all. are your sure a client-side solution using javascript isn’t sufficent to your needs?
    because the easiest way to count nodes within an HTML document is using jQuery on the client-side browser.

    <script src="http://code.jquery.com/jquery-1.7.min.js"></script>
    <script>
        $('html').children() // will give you all child elements of the html element
        $('body').children() // same for body element
        $('body').children('div') // will give you just the direct children elements of 'div' type
        $('body').find('div') // will give you all the nested elements of 'div' type
    </script>
    

    if you are unfamilier with jQuery then take a look at http://www.jquery.com

    if u still need a C# solution for server-side parsing of the document then then i would recommend to use HTMLAgilityPack (even thou you wish not to). writing your own parser seems to me like a waste of time as you need to consider malformed html/xml and such which can be a pain.

    try and use this s-overflow article: What is the best way to parse html in C#?

    hope it will satisfy your needs

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

Sidebar

Related Questions

Is there any easy way using the api to get a count of all
Is there an easy way to read an entire Access file (.mdb) into a
Is there an easy way to count the number of pages is a Word
Is there an easy way to count the number of active users or guests
I'm trying to figure out if there is an easy way to count the
Is there any 'easy' way of having pure objective-c containers, such as NSMutableDictionary or
Is there an easy way to count the lines of code you have written
is there an easy way to count uppercase words within a string?
Is there an easy way to comment out a loop which renders some html
Is there an easy way to count the number of multiplications actually executed by

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.