convert xhtml to plaintext in .net

vb.net , Xhtml , .net , text Sydney, Australia
  • 10 years ago

    Hi,

    I am trying to read an xml file.It has some xhtml data as node value.I want to convert that to plain text to save into the database.

    this is an example text:

    Her social-climbing stepmother would give anything to have Madelyn Haywood betrothed to a future duke. But believes the brothers Devine to be nothing more than heartless rogues—especially Gabriel, whose rakish reputation precedes him. He is nothing more than a slave to passion, and she will not be conquered by his caresses­—and yet his wicked ways tempt her so . . .

    Could someone help me how can i convert this type of text to plain text.I want to get rid of that hexadecimal chars and html tags.

    I tried this code.But not worked.

    Dim sb.Append(schild.InnerText)

    Dim sb As New StringBuilder

    Dim sr As New StringWriter(sb)

    Dim htr As New System.Web.UI.HtmlTextWriter(sr)

    'c1.RenderControl(htr)

    SbAboutbook.AppendLine(line)

    Dim lines As String() = htr.InnerWriter.ToString().Split(New String() {vbCr & vbLf}, StringSplitOptions.None)

    Dim SbAboutbook As New StringBuilder

    For Each line As String In lines

    SbAboutbook.AppendLine(line)

    Next blurb = SbAboutbook.ToString()

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match” - Bill Bryson