Re: [PHP] Good HTML parser needed

[email protected] (Robert Cummings)
Newsgroups php.general
Organization InterJinn
Message-ID <1210656860.21547.15.camel@blobule>
On Tue, 2008-05-13 at 01:27 -0400, Robert Cummings wrote:
> On Tue, 2008-05-13 at 12:28 +0800, Shelley wrote:
> > Maybe I didn't use that tidy correctly.
> > I don't want html, head, body things. Just parsed string.
> 
> So strip them...
> 
> <?php
>     // ...
> 
>     tidy_parse_string( $html );
>     tidy_clean_repair();
> 
>     $html = tidy_get_output();
> 
>     $html = preg_replace( '#^.*<body>#Uis', '', $html )
>     $html = preg_replace( '#</body>#Uis', '', $html )
> 
>     //...
> ?>

Whoops... noticed some bugs there :B

<?php

    $html = preg_replace( '#^.*<body>#Uis', '', $html );
    $html = preg_replace( '#</body>.*$#Uis', '', $html );

?>

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.