Google Answers Logo
View Question
 
Q: PHP HTML to Text Conversion ( No Answer,   1 Comment )
Question  
Subject: PHP HTML to Text Conversion
Category: Computers > Programming
Asked by: nkans-ga
List Price: $2.00
Posted: 29 Oct 2002 19:52 PST
Expires: 28 Nov 2002 19:52 PST
Question ID: 92746
I'm looking for a PHP script which can convert HTML File into Text
file provided it should not just only remove the tags. It should be
capable of auto align and decision making scripts to look similar like
html file.

I'm looking for a Free PHP scripts.

Example of conversion needed:

<table> <tr><td>1</td><td>2</td></tr><tr><td>col1</td><td>col2</td></tr></table>

Should give a text file

    1       2
   col1    col2 

Thanks

Request for Question Clarification by duncan2-ga on 29 Oct 2002 20:23 PST
Hi nkans,

While this is a fairly simple question, it poses a lot of problems. 
There are lots of scripts that can easily rip all the html tags from a
page, but I've never seen one that provides proper table-formatting
support.  This is probably because tables in HTML can accomplish
things which won't necessarily translate well in plain text.

For instance, tables with cells that are merged together (using column
or row spanning) may not have a direct equivalent in text.  Would you
be converting all pages to a monospaced font such as courier?  What
would you do about text that line-wrapped inside a table cell?  As
plain text, it might take a different amount of space.  And are all
the tables you'll deal with simple tabular data?  What about instances
of table inside tables?

Clarification of Question by nkans-ga on 30 Oct 2002 02:27 PST
Hi duncan2,

     ralmin-ga gave me the answer what I'm exactly looking for. But I
just need as a PHP script since I cannot ask my webserver
administrator to install this program, they will say security problem
blah blah ...

     I have seen various great Windows applications on this, but could
not find a PHP script for this.

    Thanks
    nkans
Answer  
There is no answer at this time.

Comments  
Subject: Re: PHP HTML to Text Conversion
From: ralmin-ga on 29 Oct 2002 22:30 PST
 
There is a free text-based web browser called Links that can render
HTML tables into plain text like you want. Once the program is
installed on your server, you can probably set up a PHP script to run
the command:
   links -dump filename.html

http://links.sourceforge.net/

-- 
Ralmin.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy