NAME

HTML::Manipulator::Document - object-oriented interface to HTML::Manipulator

SYNOPSIS

  use HTML::Manipulator::Document;
  
  my $doc = HTML::Manipulator::Document->from_file('test.html');
  print $doc->replace('headline'=>'New Headline');
  
  print $doc->as_string;

DESCRIPTION

This module provides an object-oriented interface to the functions of the HTML::Manipulator module. It also has an additional feature to load HTML from file.

You use it by calling one of the two constructor methods, which return an object of this class. The object has methods that mirror the functions of HTML::Manipulator.

Constructors

Instances can be be created from HTML documents in memory (contained in a string) or from a file.

  my $doc = HTML::Manipulator::Document->from_string('<html>blah</html>');
  
  my $doc = HTML::Manipulator::Document->from_file('test.html');
  
The from_file() constructor takes a file handle
or a file name.
  

HTML::Manipulator methods

All of the functions of HTML::Manipulator are available as methods.

In HTML::Manipulator, the first parameter is always the HTML text. In the object-oriented interface the HTML document was already specified in the constructor, making the parameter obsolete. You must therefore omit that first parameter.

For example

my $new = HTML::Manipulator::replace($html, 
     title => 'New news', headline77=>'All clear?');

becomes

my $obj = HTML::Manipulator::Document->from_string($html);
my $new = $obj->replace(
	 title => 'New news', headline77=>'All clear?');

The methods return the same results as the functions they wrap. See HTML::Manipulator for details on what functions there are and how they work.

replace() method

In addition to returning the new HTML text, the replace() method also changes the content of the HTML document represented by the object.

as_string() method

Use this method to get the HTML content from the object.

SEE ALSO

HTML::Manipulator

perltoot

AUTHOR

Thilo Planz, <planz@epost.de>

COPYRIGHT AND LICENSE

Copyright 2004 by Thilo Planz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.