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

  • SEARCH
  • Home
  • 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 639873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:53:27+00:00 2026-05-13T20:53:27+00:00

Using the HTML Agility Pack , how can I remove all HTML attributes, elements,

  • 0

Using the HTML Agility Pack, how can I remove all HTML attributes, elements, etc, etc, from a blob of HTML, with the result as if I pasted it into notepad?

Additionally, I need to remove all formatting but I need to keep UL/LI and B tags.

  • 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-13T20:53:27+00:00Added an answer on May 13, 2026 at 8:53 pm

    Enter the html into an HtmlDocument instance, you can get the HtmlNode returned by the DocumentNode property, and from there, get the InnerText property of the document node. It will give you all the text stripped of HTML tags.

    If you want to only include a particular subset of nodes in your filtering, then it’s going to be a little more difficult.

    First, you would load the content into an HtmlDocument instance and get the HtmlNode instance returned by the DocumentNode property (I’ll refer to this node from this document as the root node).

    At the same time, you would also create a second HtmlDocument instance which would contain the new document you are creating.

    On the first document, you would iterate through the root node recursively (note, it doesn’t have to be an actual recursive method, but semantically it would be recursive behavior), analyzing the node and all of it’s children nodes.

    If the node itself is one of the nodes you approve of, then you would begin to construct a new instance of that node.

    However, if it is not, you would still process the child nodes of the element, getting the text node content (since text in itself is a node) and appending it to whatever current node is on the stack (if there is one).

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

Sidebar

Related Questions

I'm using the HTML agility pack to scrape a website. I'm looking though all
Using the html agility pack; how would I extract an html fragment from a
I'm using Html Agility Pack to fetch a webpage. I want to collect all
Using the HTML Agility Pack is great for getting descendants and whole tables etc...
im using HTML Agility Pack to fetch URLs from w webpage. The URL is:
I am using HTML Agility Pack to parse html content. I am using parsing
I am using html agility pack to parse html tabular information . Now there
I want to parse the html table using html agility pack. I want to
I've looked for tutorials on using HTML Agility Pack as it seems to do
I am trying to stop XSS attack so I am using html agility pack

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.