Removing all except couple of html tags from html file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing all except couple of html tags from html file
# 1  
Old 06-21-2012
Removing all except couple of html tags from html file

I tried to find elegant (or at least simple) way to remove all but couple of html tags from html file, but all examples I found dealt with removing all the tags.

The logic of the script would be:
- if there is <li> or <ul> on the line, do nothing (=write same line to output)
- if there is:
font class="titleA"
substitute it with:
<h2>
- otherwise if there is html tag, remove it (=write the lines to output without tags, just content)

Could please someone tell me how to approach this problem? I know some perl but my skills are rusty (years from last time I used perl).

Last edited by juubuntu; 06-21-2012 at 09:12 AM.. Reason: typo
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add HTML tags to file list

Hi there, I am new to shell scripting and have been struggling with this example. I have an input variable that looks like that: FILELIST="100_*_123.txt" that will produce a list of files if you use ls ${FILELIST} The output looks like 100_EN_123.txt 100_FR_123.txt I am building... (4 Replies)
Discussion started by: ornesey
4 Replies

2. Homework & Coursework Questions

Script: Removing HTML tags and duplicate lines

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: You will write a script that will remove all HTML tags from an HTML document and remove any consecutive... (3 Replies)
Discussion started by: tburns517
3 Replies

3. UNIX for Advanced & Expert Users

Mutt for html body and multiple html & pdf attachments

Hi all: Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project. There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues. Running with... (1 Reply)
Discussion started by: raggmopp
1 Replies

4. Shell Programming and Scripting

Removing html tags

I store different variance of the below in an xml file. and apparently, xml has an issue loading up data like this because it contains html tags. i would like to preserve this data as it is, but unfortunately, xml says i cant. so i have to strip out all the html tags. the examples i found... (9 Replies)
Discussion started by: SkySmart
9 Replies

5. Shell Programming and Scripting

Parsing HTML, get text between 2 HTML tags

Hi there, I'm quite new to the forum and shell scripting. I want to filter out the "166.0 points". The results, that i found in google / the forum search didn't helped me :( <a href="/user/test" class="headitem menu" style="color:rgb(83,186,224);">test</a><a href="/points" class="headitem... (1 Reply)
Discussion started by: Mysthik
1 Replies

6. UNIX for Advanced & Expert Users

Removing HTML tags

Hello Unix Gurus I am having a problem with one of the files that i am generating using a Unix Script. This Unix Scripts connects to the MY SQL Server and loads the data into a Text file. While generating the Text file for one of the tables the value in one of the column is as follows. <p>... (3 Replies)
Discussion started by: chetan.mudike
3 Replies

7. Red Hat

Send HTML body and HTML attachment using MUTT command

Hi there.. I need a proper "mutt" command to send a mail with html body and html attachment at a time. Also if possible let me know the other commands to do this task. Please help me.. (2 Replies)
Discussion started by: vickramshetty
2 Replies

8. Shell Programming and Scripting

searching & replacing/removing only certain HTML tags

I generally save a lot of web pages for reading offline which works out great for school. Now I have to spend a lot of time on the bus and I am looking for the best way to read some of these webpages using my Nokia 7610. I have uploaded the files to my phone, but they are deadly deadly slow to... (2 Replies)
Discussion started by: naphelge
2 Replies

9. Shell Programming and Scripting

removing html tags via parameter expansion

Hi all- I have a variable that contains a web page: echo $STUFF <html> <head> <title>my page</title></head> <body> blah blah etc.. Can I use the shell's parameter expansion abilities to remove just the tags? I thought that FIXHTML=${STUFF//<*>/} might do it, but it didn't seem to... (2 Replies)
Discussion started by: rev66
2 Replies

10. UNIX for Dummies Questions & Answers

How do I extract text only from html file without HTML tag

I have a html file called myfile. If I simply put "cat myfile.html" in UNIX, it shows all the html tags like <a href=r/26><img src="http://www>. But I want to extract only text part. Same problem happens in "type" command in MS-DOS. I know you can do it by opening it in Internet Explorer,... (4 Replies)
Discussion started by: los111
4 Replies
Login or Register to Ask a Question
XML::Writer::Simple(3pm)				User Contributed Perl Documentation				  XML::Writer::Simple(3pm)

NAME
XML::Writer::Simple - Create XML files easily! SYNOPSIS
use XML::Writer::Simple dtd => "file.dtd"; print xml_header(encoding => 'iso-8859-1'); print para("foo",b("bar"),"zbr"); # if you want CGI but you do not want CGI :) use XML::Writer::Simple ':html'; USAGE
This module takes some ideas from CGI to make easier the life for those who need to generated XML code. You can use the module in three flavours (or combine them): tags When importing the module you can specify the tags you will be using: use XML::Writer::Simple tags => [qw/p b i tt/]; print p("Hey, ",b("you"),"! ", i("Yes ", b("you"))); that will generate <p>Hey <b>you</b>! <i>Yes <b>you</b></i></p> dtd You can supply a DTD, that will be analyzed, and the tags used: use XML::Writer::Simple dtd => "tmx.dtd"; print tu(seg("foo"),seg("bar")); xml You can supply an XML (or a reference to a list of XML files). They will be parsed, and the tags used: use XML::Writer::Simple xml => "foo.xml"; print foo("bar"); partial You can supply an 'partial' key, to generate prototypes for partial tags construction. For instance: use XML::Writer::Simple tags => qw/foo bar/, partial => 1; print start_foo; print ... print end_foo; You can also use tagsets, where sets of tags from a well known format are imported. For example, to use HTML: use XML::Writer::Simple ':html'; EXPORT
This module export one function for each element at the dtd or xml file you are using. See below for details. FUNCTIONS
import Used when you 'use' the module, should not be used directly. xml_header This function returns the xml header string, without encoding definition, with a trailing new line. Default XML encoding should be UTF-8, by the way. You can force an encoding passing it as argument: print xml_header(encoding=>'iso-8859-1'); powertag Used to specify a powertag. For instance: powertag("ul","li"); ul_li([qw/foo bar zbr ugh/]); will generate <ul> <li>foo</li> <li>bar</li> <li>zbr</li> <li>ugh</li> </ul> You can also supply this information when loading the module, with use XML::Writer::Simple powertags=>["ul_li","ol_li"]; Powertags support three level tags as well: use XML::Writer::Simple powertags=>["table_tr_td"]; print table_tr_td(['a','b','c'],['d','e','f']); AUTHOR
Alberto Simo~es, "<ambs@cpan.org>" BUGS
Please report any bugs or feature requests to "bug-xml-writer-simple@rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-Writer-Simple <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-Writer-Simple>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. COPYRIGHT AND LICENSE
Copyright 1999-2012 Project Natura. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-06-05 XML::Writer::Simple(3pm)