Click here to get back home

HTTP::TreeBuilder problems

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
HTTP::TreeBuilder problems John W. Kennedy 07-29-2004
Get Chitika Premium
Posted by John W. Kennedy on July 29, 2004, 12:19 am
Please log in for more thread options
I'm trying to build an HTML-altering program using HTTP::TreeBuilder,
but am having a problem dealing with comments. I have "savecomments"
turned on, and the comments are being put into the tree, but they're all
dumped in at the end, between </body> and </html>.

The additional error with DOCTYPE is documented, and I can deal with it,
but the destruction of the context of comments is ruinous for my purposes.

Current program:

use strict;
use warnings;
use HTML::TreeBuilder;
my $tree = HTML::TreeBuilder->new();
$tree->store_comments (1);
$tree->store_declarations (1);
$tree->parse_file ('text.html');
$tree->elementify;
print $tree->as_HTML;
$tree->delete;

Current input:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--This is a comment before html-->
<html>
<!--This is a comment before head-->
<head>
<title>Test</title>
</head>
<body>
<p>This is it.</p>
</body>
</html>
<!--This is a comment after html-->

Current output:

<html><head><title>Test</title></head><body><p>This is
it.</body><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN"><!--This is a comment before html--><!--This is a
comment before head--><!--This is a comment after html--></html>


Similar ThreadsPosted
Possible Issue with HTML::TreeBuilder? July 5, 2005, 6:49 am
HTML::TreeBuilder eating my entities using perl 5.8.x May 18, 2005, 3:08 am
XML-RPC over HTTP with SSL January 17, 2005, 10:08 pm
Using HTTP::Proxy September 23, 2004, 5:41 am
HTTP::ProxySelector March 17, 2006, 9:51 am
HTTP::Proxy and not using 127.0.0.1 May 11, 2006, 6:10 pm
HTTP::Cache module September 26, 2004, 8:37 am
http request headers October 1, 2004, 12:47 pm
http headers with CGI.pm and mod_perl (bug?) November 10, 2004, 10:19 pm
HTTP 1.1 Support in LWP / ParallelUA February 11, 2006, 2:20 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap