473,386 Members | 1,763 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,386 software developers and data experts.

HTML to Plain Text

Can anybody suggest how to remove html tags while displaying the output

consider code as
<b> name </b>

now i want to display output in perl as
name.


reply as soon as possible.....
Feb 19 '07 #1
4 22410
KevinADC
4,059 Expert 2GB
if you don't need or want to go the full html parser route:

http://perldoc.perl.org/perlfaq9.htm...om-a-string%3F

but if you do:

http://search.cpan.org/author/GAAS/H...3.56/Parser.pm
Feb 19 '07 #2
miller
1,089 Expert 1GB
You basically have three options (and variations there of). Which method you choose depends on what the content of your html is, and what type of output that you want. Most likely, you'll use either method #1 or #3.

1) Remove Tags using a regular expression (Quick and Dirty) (Kevin's Suggestion #1)

Perl FAQ 9 - Removing HTML from String

2) HTML Parser - By tag parsing of html (Complicated and Verbose) (Kevin's Suggestion #2)

cpan HTML::Parser

3) HTML::FormatText - Generic Parsing of HTML to Plain Text

cpan HTML::FormatText
Feb 19 '07 #3
Thks frds for yr replies,



My problem got solved by using follwing code line

$record=~s/<.*?>/ /g;
Feb 21 '07 #4
miller
1,089 Expert 1GB
Thks frds for yr replies,

My problem got solved by using follwing code line

$record=~s/<.*?>/ /g;
Well done.

That was the first method suggested in the FAQ link. Read the first paragraph (excerpted below) to make sure that you aren't overlooking anything if this is a repeated need:

Many folks attempt a simple-minded regular expression approach, like s/<.*?>//g, but that fails in many cases because the tags may continue over line breaks, they may contain quoted angle-brackets, or HTML comment may be present. Plus, folks forget to convert entities--like &lt; for example.
Feb 21 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: J. Alan Rueckgauer | last post by:
Hello. I'm looking for a simple way to do the following: We have a database that serves-up content to a website. Some of those items are events, some are news articles. They're stored in the...
1
by: Karl B | last post by:
Hi all. Iv'e tryed out xp_smtp_sendmail, and I like what I can see so far. The thing I wonder about is if the xp supports sending both html AND plain text in the same mail. I'm on a sql2000 sp3 and...
14
by: Akseli Mäki | last post by:
Hi, Hopefully this is not too much offtopic. I'm working on a FAQ. I want to make two versions of it, plain text and HTML. I'm looking for a tool that will make a plain text doc out of the...
8
by: LRW | last post by:
I'm not sure this message is totally appropriate for this group, so please, if anyone has a better group suggestion, let me know! My company sends out a monthly newsletter in HTML format to our...
3
by: tdeclercq | last post by:
HI, I want to be sure that users receive and can read my mails. How can I send mail in HTML AND text Format in one send ? thx
58
by: Jeff_Relf | last post by:
Hi Tom, You showed: << private const string PHONE_LIST = "495.1000__424.1111___(206)564-5555_1.800.325.3333"; static void Main( string args ) { foreach (string phoneNumber in Regex.Split...
10
by: Eric Lindsay | last post by:
This may be too far off topic, however I was looking at this page http://www.hixie.ch/advocacy/xhtml about XHTML problems by Ian Hickson. It is served as text/plain, according to Firefox...
6
by: monomaniac21 | last post by:
hi all how can u send a plain text version of an email with the html so that the users mail client can access this plain text version? kind regards marc
0
by: Rey | last post by:
Howdy all. Am using visual web developer 2005 (vb), xp pro sp2. In testing of the system.net.mail to send email from an aspx page where I'm pulling the email contents from a textbox, find that...
2
by: =?Utf-8?B?Q2FwdGFpbiBEYXZlIQ==?= | last post by:
I wrote some code to send an email with two alternate views: 1) html 2) plain text All the html enabled email clients accept the html just fine and disregard the plain text version. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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.