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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:49:04+00:00 2026-06-14T20:49:04+00:00

I have tried using (and have been advised against) using regular expressions for this

  • 0

I have tried using (and have been advised against) using regular expressions for this task (here) – and so instead i tried using the HTMLAgilityPack in this manner however its resulting text is very poor, html lists (<ol><li></ol>) are completely lost and just result in clumped together paragraphs.

In this question i saw that lynx (compiled for windows) was recommended as a good alternative, however i am having trouble getting this working – how would one use lynx.exe to convert html (stored in a .net string) to a presentable plain text string with line breaks etc.

The only way i can think off is by writing the html to a file, using .nets system.process to call lynx.exe -dump and read the resulting file – this seems very clumsy.

Is there a better way of doing it?
What would the exact lynx.exe command line be for such a task?

The LYNX implementation i am using is this one:

http://invisible-island.net/datafiles/release/lynx-cs-setup.exe

Edit: Made some progress, this is the command line i’ve been using:

lynx.exe -dump "d:\test.html" >d:\output.txt

It sort of works but if i open the resulting file in notepad its all on one line (because lynx is only using Line Feed characters for new lines whereas notepad needs carriage returns to render properly.

Also, its inserting way too many line feeds after </li> & <br /> tags its doing two Line Feeds:

   Hello, this is a normal line of text.


   Next an ordered list:


   1.       The

   2.       Quick

   3.       Brown Fox

   4.       Jumped

I can work around this by replacing two consecutive LF’s with just the one LF, but i’m still after a c# wrapper for all this.

Edit 2 – My final solution based on Christian’s answer:

Function ConvertHtmlToPlainText(ByVal HtmlString As String) As String

    '#### Define FileBuffer Path
    Dim HtmlBuffer As String = WorkingRoot & "HtmlBuffer.html"

    '#### Delete any old buffer files
    Try
        If File.Exists(HtmlBuffer) = True Then
            File.Delete(HtmlBuffer)
        End If
    Catch ex As Exception
        Return "Error: Deleting old buffer file: " & ex.Message
    End Try

    '#### Write the HTML to the buffer file
    Try
        File.WriteAllText(WorkingRoot & "HtmlBuffer.html", HtmlString)
    Catch ex As Exception
        Return "Error: Writing new buffer file: " & ex.Message
    End Try

    '#### Check the file was written OK
    If File.Exists(HtmlBuffer) = False Then
        Return "Error: HTML Buffer file was not written successfully."
    End If

    '#### Read the buffer file with Lynx and capture plain text output
    Try
        Dim p = New Process()
        p.StartInfo = New ProcessStartInfo(LynxPath, "-dump -width 1000 " & HtmlBuffer)
        p.StartInfo.WorkingDirectory = WorkingRoot
        p.StartInfo.UseShellExecute = False
        p.StartInfo.RedirectStandardOutput = True
        p.StartInfo.RedirectStandardError = True
        p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
        p.StartInfo.CreateNoWindow = True
        p.Start()
        p.WaitForExit()

        '#### Grab the text rendered by Lynx
        Dim text As String = p.StandardOutput.ReadToEnd()
        Return text.Replace(vbLf & vbLf, vbLf)

    Catch ex As Exception
        Return "Error: Error running LYNX to parse the buffer: " & ex.Message
    End Try
End Function
  • 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-06-14T20:49:06+00:00Added an answer on June 14, 2026 at 8:49 pm

    Using this you can invoke Lynx, grab the output from the redirected StandardOutput into a string without writing it to a file first.

    using System;
    using System.Diagnostics;
    
    namespace Lynx.Dumper
    {
      public class Dampler
      {
          public void fdksfjh()
          {
              var url = "http://www.google.com";
    
              var p = new Process();
    
              p.StartInfo = new ProcessStartInfo("c:/tools/lynx_w32/lynx.exe", "-dump -nolist " + url)
              {
                  WorkingDirectory = "c:/tools/lynx_w32/",
                  UseShellExecute = false,
                  RedirectStandardOutput = true,
                  RedirectStandardError = true,
                  WindowStyle = ProcessWindowStyle.Hidden,
                  CreateNoWindow = true
              };
    
              p.Start();
              p.WaitForExit();
    
              //grab the text rendered by Lynx
              var text = p.StandardOutput.ReadToEnd();
    
              Console.WriteLine(text);
          }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been at this for a bit now, and I have tried using google
I have tried all the solutions that have been provided including using PRAGMA but
All right so I tried using the button set. So fair, I have been
I have been parsing a GraphViz file for a specific identifer using Regex. Here
I have been parsing a GraphViz file for a specific identifer using Regex. Here
I have been using Javascript for a while and I have just tried using
I have been trying to install VS2010 SP1. I have tried Using both the
I have been checking Google for an hour. I have tried using typdef but
I have tried using the code below but it only display results in Chrome
I have tried using a stemmer but the words it produces are just not

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.