473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 7049
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.com> wrote in message
news:43***********************@newsread4.arcor-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.com> 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.HtmlEncode'.

XML encoding:

\\\
Imports System.Text
Imports System.Xml
..
..
..
Public Function XmlEncode(ByVal Text As String) As String
Dim sb As New StringBuilder(Text.Length)
Dim tw As New XmlTextWriter(New 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********************@z14g2000cwz.googlegrou ps.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********************@z14g2000cwz.googlegrou ps.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
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....
7
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. ...
4
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...
4
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...
2
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...
14
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...
7
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...
23
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.