HTML::TreeBuilder::toSAX - SAX export of HTML::TreeBuilder trees
  use HTML::TreeBuilder::toSAX;
  
  my $tree= HTML::TreeBuilder::toSAX->new();
  $tree->parse_file( 'example.html');
  # write using a SAX1 writer
  use XML::Handler::YAWriter;
  my $writer1 = XML::Handler::YAWriter->new( AsFile => '-', Pretty => $pretty);
  $tree->toSAX1( $writer1);
  
  # write using a SAX2 writer
  use XML::SAX::Writer;
  my $writer2 = XML::SAX::Writer->new( );
  $tree->toSAX2( $writer2);
  
HTML::TreeBuilder::toSAX is a subclass of HTML::TreeBuilder that allows SAX export for a tree.
The tree itself is subclassed as an HTML::TreeBuilder::toSAX object, and its elements are subclassed as HTML::Element::toSAX instead of the normal HTML::Element
SAX1 export of a tree
SAX2 export of a tree
the code for parsing the XML declaration, if present, and the document (<!DOCTYPE ...) declaration is very crude and most likely buggy
with the current (3.13) version of HTML::TreeBuilder some of the elements are not properly subclassed as HTML::Element::toSAX until after the tree has been exported using a toSAXn method
with the current (3.13) version of HTML::TreeBuilder you cannot use the elementify method on a tree prior to exporting with a toSAXn method
more tests are (always!) needed, especially SAX1 tests
Perl SAX
Michel Rodriguez, <mirod@cpan.org>
Copyright (C) 2004 by Michel Rodriguez
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.