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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:33:15+00:00 2026-05-25T22:33:15+00:00

I am creating a HTML to text parser. I need to remove all HTML

  • 0

I am creating a HTML to text parser. I need to remove all HTML elements and want to do a carriage return everytime there is a <BR> and then remove the <BR> as well after so there are no HTML tags left. I then want to parse the text for a certain string that is in the combobox. Thank you in advance for your help.

private void navigateWeb_Click(object sender, EventArgs e)
    {

        openFD.Title = "Select your configuration file";
        openFD.InitialDirectory = "C:";
        openFD.FileName = "";
        openFD.Filter = "Config File (*.cfg)|*.cfg|Text File (*.txt)|*.txt|All Files (*.*)|*.*";
        openFD.ShowDialog();
        MyURL = openFD.FileName;
        //Open and read file
        System.IO.StreamReader objReader;
        objReader = new System.IO.StreamReader(MyURL);
        richTextBox1.Text = objReader.ReadToEnd();

        var lines = File.ReadAllLines(MyURL)
            .Select(l => l.Trim())
            .Where(l => l.StartsWith(comboBox1.Text));
        textBox1.Text = String.Join(Environment.NewLine, lines);


    }

*********UPDATE*****
Here is the solution that got the job done:

 public static string RemoveHTML(string text)
    {
        text = text.Replace("&nbsp;", " ").Replace("<br>", "\n");
        var oRegEx = new System.Text.RegularExpressions.Regex("<[^>]+>");
        return oRegEx.Replace(text, string.Empty);

    } 
private void navigateWeb_Click(object sender, EventArgs e)
{

    openFD.Title = "Enter URL in the box below";
    openFD.InitialDirectory = "C:";
    openFD.FileName = "http://msnconf/configtc.aspx?IP=10.6.64.200&m=c";
    openFD.Filter = "HTTP://|*.*|Config File (*.cfg)|*.cfg|Text File (*.txt)|*.txt|All Files (*.*)|*.*";



    //openFD.ShowDialog();
    if (openFD.ShowDialog() == DialogResult.Cancel)
    {
        //MessageBox.Show("cancel button clicked");
    }
    else
    {
        MyURL = openFD.FileName;

        webBrowser1.Visible = true;
        richTextBox1.Visible = false;
        permitACL.Enabled = true;


        //webBrowser1.Navigate(new Uri(MyURL.SelectedItem.ToString()));
        webBrowser1.Navigate(MyURL);
        //Open and read file
        System.IO.StreamReader objReader;
        objReader = new System.IO.StreamReader(MyURL);
        richTextBox1.Text = objReader.ReadToEnd();




        //Read all lines of file
        //            String lines = objReader.ReadToEnd();
        String[] crString = { "<BR>&nbsp;" };
        String[] aLines = richTextBox1.Text.Split(crString, StringSplitOptions.RemoveEmptyEntries);
        //            String[] lines = File.ReadAllLines(MyURL);
        String noHtml = String.Empty;

        for (int x = 0; x < aLines.Length; x++)
        {
            if(permitACL.Checked)
            {

                if (aLines[x].Contains("permit"))
            {
                noHtml += (RemoveHTML(aLines[x]) + "\r\n");
            }

            }

            if (aLines[x].Contains(comboBox1.Text))
            {
                noHtml += (RemoveHTML(aLines[x]) + "\r\n");
            }
        }

        //Find lines that match our text in the combobox
        //lines.Select(l => l.Trim());
        //.Where(l => l.StartsWith(comboBox1.Text));



        //Print results to textbox
        textBox1.Text = String.Join(Environment.NewLine, noHtml);
    }

}
  • 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-25T22:33:16+00:00Added an answer on May 25, 2026 at 10:33 pm
    public static string RemoveHTML(string text)
    {
            text = text.Replace("&nbsp;", " ").Replace("<br>", "\n");
            var oRegEx = new System.Text.RegularExpressions.Regex("<[^>]+>");
            return oRegEx.Replace(text, string.Empty);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to remove all html tag from the text. But I don't want
Is there a well maintained package available in Python for creating and validating HTML
I am creating some html from code running on a WinForm. I want to
I'm creating a mail object like so: textpart_to_inject= params[:text] htmlpart_to_inject= params[:html] message_all = Mail.new
I am creating html element ids by escaping text phrases, as follows: var elementid=escape('some
I am creating a user control where in i have different HTML text boxes
I'm creating HTML with a loop that has a column for Action. That column
I am creating an HTML form with some radio button options. I'd like to
I have a website that right now, runs by creating static html pages from
When creating links for an an html based email, how critical is it to

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.