473,569 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert HTML -> PlainText (-> HTML)

Hey there,

mmmm does anyone know a library or anything I can use to convert
plaintext to html real quick and vice-versa? Regex surely would do the
trick to a certain level, but maybe there's already a useful library out
there which I might have a look at..

Thanks,
-J
Nov 29 '05 #1
6 7068
I could see the HTML -> plain text. But how do you convert plain text to
html? I mean, at that point, all your have is the text, and none of the
formatting, none of the elements. How would you figure out what to put
where?

You can use MSHTML to strip out all HTML formatting.

"Joerg Battermann" <jb@justbe.co m> wrote in message
news:43******** *************** @newsread4.arco r-online.net...
Hey there,

mmmm does anyone know a library or anything I can use to convert plaintext
to html real quick and vice-versa? Regex surely would do the trick to a
certain level, but maybe there's already a useful library out there which
I might have a look at..

Thanks,
-J

Nov 29 '05 #2
"Joerg Battermann" <jb@justbe.co m> schrieb:
mmmm does anyone know a library or anything I can use to convert plaintext
to html real quick and vice-versa?


I am not sure what exectly you want to archieve, but maybe you want to
encode characters like "<", ">", etc. using according named character
entities:

Text -> HTML

'HttpUtility.Ht mlEncode'.

XML encoding:

\\\
Imports System.Text
Imports System.Xml
..
..
..
Public Function XmlEncode(ByVal Text As String) As String
Dim sb As New StringBuilder(T ext.Length)
Dim tw As New XmlTextWriter(N ew StringWriter(sb ))
tw.WriteString( Text)
tw.Flush()
Return sb.ToString()
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 30 '05 #3
Joerg,

For HTML to plain text see the advice from Marina, the other way around can
be as simple as

Before your text
<html><body>
after it
</body></html>

However probably do you not mean plain text.

Cor
Nov 30 '05 #4
Cor,

I actually did mean sorta plaintext... or to be more exact text I
extract from an Excel Cell.

I am currently writing a synchronizer that allows user to sync. data
that is stored partially in an excel file and partially in a caliberrm
database (which holds it's data partially in some more or less valid
html-format).

The tool shall be able to sync the data, but prior to writing back to
caliber, I have to convert it back to html and i was thinking about
simply putting a html & body tag before and at the end of it plus
converting line breaks etc to br's, but I thought maybe there's
something more sophisticated already out there.
Ideally I would be looking for something that gives me valid html code
out of a excel cell's content (like bold, italic etc formating), but I
think that's sort of close to utopia.

Dec 1 '05 #5
Joerg,

I got that idea, you can than have a look to office interop, although you
would than have office installed to do that and create a doc, which you than
save as HTML (better to say ugly HTML).

Be aware that those fonts descriptions are the hardest to set in HTML by
hand (program). They need a lot of tags and it is mostly close to an utopia.

:-)

Cor


Cor

"Joerg Battermann" <jo************ **@gmail.com> schreef in bericht
news:11******** ************@z1 4g2000cwz.googl egroups.com...
Cor,

I actually did mean sorta plaintext... or to be more exact text I
extract from an Excel Cell.

I am currently writing a synchronizer that allows user to sync. data
that is stored partially in an excel file and partially in a caliberrm
database (which holds it's data partially in some more or less valid
html-format).

The tool shall be able to sync the data, but prior to writing back to
caliber, I have to convert it back to html and i was thinking about
simply putting a html & body tag before and at the end of it plus
converting line breaks etc to br's, but I thought maybe there's
something more sophisticated already out there.
Ideally I would be looking for something that gives me valid html code
out of a excel cell's content (like bold, italic etc formating), but I
think that's sort of close to utopia.

Dec 1 '05 #6
Cor,

thanks for the reply everything - I'll see what I'll do. Converting via
Word is somewhat impossible, because I am currently handling a couple
thousand requirements and doing a temp. save and import to caliber might
take a little longer than forever. Maybe I just tell the user that
importing to caliber is a no-go.

Thanks and have a great day,
-Joerg :)

Cor Ligthert [MVP] wrote:
Joerg,

I got that idea, you can than have a look to office interop, although you
would than have office installed to do that and create a doc, which you than
save as HTML (better to say ugly HTML).

Be aware that those fonts descriptions are the hardest to set in HTML by
hand (program). They need a lot of tags and it is mostly close to an utopia.

:-)

Cor


Cor

"Joerg Battermann" <jo************ **@gmail.com> schreef in bericht
news:11******** ************@z1 4g2000cwz.googl egroups.com...
Cor,

I actually did mean sorta plaintext... or to be more exact text I
extract from an Excel Cell.

I am currently writing a synchronizer that allows user to sync. data
that is stored partially in an excel file and partially in a caliberrm
database (which holds it's data partially in some more or less valid
html-format).

The tool shall be able to sync the data, but prior to writing back to
caliber, I have to convert it back to html and i was thinking about
simply putting a html & body tag before and at the end of it plus
converting line breaks etc to br's, but I thought maybe there's
something more sophisticated already out there.
Ideally I would be looking for something that gives me valid html code
out of a excel cell's content (like bold, italic etc formating), but I
think that's sort of close to utopia.


Dec 1 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2204
by: news | last post by:
Before I begin, I realise there's a big war regarding HTML in e-mails. Personally, I don't like it. Unfortunately, I'm being paid by my company to create an automated newsletter for our customers. I did all I could just to get them to allow me to have it sent in both plaintext and HTML so that the e-mail clients have a choice. Anyway. I've...
7
12282
by: Robert Oschler | last post by:
Is there a module/function to remove all the HTML entities from an HTML document (e.g. - &nbsp, &amp, &apos, etc.)? If not I'll just write one myself but I figured I'd save myself some time. Thanks, -- Robert
4
2212
by: Nicole | last post by:
Hello, Can anyone tell me or give me an online tool which can help me to convert php dynamic urls to html urls to make a google friendly site.I dont have apache server on my computer and I dont want to use it.Wihtout apache server is it possible? And I amusing windows server and not Linux. Thanks Sunita Bihani
4
4457
by: csgraham74 | last post by:
Hi, Ive posted on this previously but had no response. Basically i need to build some html using a rich text editor. Then i want to actually create an html document from this and save it to my server. Does anyone have any examples on how to do this ?? I dont really understand how to get from HTML string to HTML document. I can probably...
2
10712
by: Sreenath Rao Nellutla | last post by:
Hai all, I am trying to create dropdown calendar control with HTML input control by writing JavaScript. But while executing I am getting the error as "Error on Page" on the status bar of the browser. I wrote the following code in the HTML code for the web form: <%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false"...
14
3127
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the PHP interpreter works like any other, that is, it first expands all the include files, and then parses the resulting text. Can anyone help with an...
7
1843
by: Luca Villa | last post by:
I have many html files named like these: c:\dir\femo-black.html c:\dir\loren-white.html c:\dir\spark-white.html c:\dir\kim-black.html c:\dir\paul-white.html How can I convert only the files named "c:\dir\*-white.html" to plaintext files named c:\dir\(original filename)-text.txt?
23
2217
by: Xah | last post by:
Here's a interesting case of invalid html 4 strict file. In summary, if you have <body></bodywithout any content, the file would be invalid under html 4 strict. Valid if html 4 lose. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ TR/html4/strict.dtd"> <html> <head> <META HTTP-EQUIV="Content-Type"...
2
2178
by: test | last post by:
I have asked a sortlike question on this group, but this is an other approach for this problem. I want to send information about a set of 8 radiobuttons to a device that listens to TCP/IP on port 80. I have 8 sets of radiobuttons, each has a on and off state. When this form is send, I would like that the state of the buttons is converted...
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6281
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.