471,854 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,854 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 22192
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

Post your reply

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

Similar topics

10 posts views Thread by J. Alan Rueckgauer | last post: by
1 post views Thread by Karl B | last post: by
3 posts views Thread by tdeclercq | last post: by
10 posts views Thread by Eric Lindsay | last post: by
6 posts views Thread by monomaniac21 | last post: by
2 posts views Thread by =?Utf-8?B?Q2FwdGFpbiBEYXZlIQ==?= | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

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.