Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 9th, 2008, 7:30 PM   #1
abhisheksainiabhishek
Newbie
 
Join Date: Jun 2008
Posts: 12
Rep Power: 0 abhisheksainiabhishek is on a distinguished road
html tags replace

Hi,
I am writing a program in perl which opens and reads a html file and removes unnecessary tags.
For example if an html file has...
<html>
<title>this is the title</title>
<body>
<b>this is a bold text.</b><b>this is also a
bold text</b>
</body>
</html>

Since there are unnecessary bold tags..I mean it can also be written as <b>this is a bold text.this is also a bold text</b>

Please tell me if I am on the right track...

I read the html file line by line.
On each line when I encounter <b> tag I take the line into a temp string until I approach </b> tag...and I keep searching for any other string after that which uses the <b>immediately after this. I can make separate subroutine to remove the unnecessary <b> tags.

Or should I read file by per charcter encounter. I am fairly new to perl. Please advise me.
abhisheksainiabhishek is offline   Reply With Quote
Old Jun 10th, 2008, 7:55 PM   #2
casesensitive
Programmer
 
Join Date: Oct 2007
Posts: 41
Rep Power: 0 casesensitive is on a distinguished road
Re: html tags replace

Quote:
Originally Posted by abhisheksainiabhishek View Post
Hi,
I am writing a program in perl which opens and reads a html file and removes unnecessary tags.
For example if an html file has...
<html>
<title>this is the title</title>
<body>
<b>this is a bold text.</b><b>this is also a
bold text</b>
</body>
</html>

Since there are unnecessary bold tags..I mean it can also be written as <b>this is a bold text.this is also a bold text</b>

Please tell me if I am on the right track...

I read the html file line by line.
On each line when I encounter <b> tag I take the line into a temp string until I approach </b> tag...and I keep searching for any other string after that which uses the <b>immediately after this. I can make separate subroutine to remove the unnecessary <b> tags.

Or should I read file by per charcter encounter. I am fairly new to perl. Please advise me.
I dont understand the point of it. Just use classes to bold stuff. Its a lot more fun...
casesensitive is offline   Reply With Quote
Old Jun 11th, 2008, 5:55 PM   #3
abhisheksainiabhishek
Newbie
 
Join Date: Jun 2008
Posts: 12
Rep Power: 0 abhisheksainiabhishek is on a distinguished road
Re: html tags replace

I am just supposed to use regular expressions.
But I got it working now. Thanks anyways!
abhisheksainiabhishek is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Optional Closing Tags in HTML WIND HTML / XHTML / CSS 24 Jan 12th, 2008 8:13 AM
start Learning HTMl smita HTML / XHTML / CSS 0 Mar 15th, 2007 8:38 AM
Basics of HTML Tutorial crawforddavid2006 HTML / XHTML / CSS 14 Jul 11th, 2006 8:40 AM
Basic HTML Tutorial - Reuben Keeney ReubenK HTML / XHTML / CSS 14 Mar 26th, 2006 6:50 AM
HTML =/= Programming Sane Coder's Corner Lounge 32 Mar 8th, 2006 3:50 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:10 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC