469,328 Members | 1,231 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

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 21784
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.