The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

XML::SAX::RTF

XML::SAX::RTF - SAX Driver for Microsoft's Rich Text Format (RTF)

SYNOPSIS

  use XML::SAX::ParserFactory;
  use XML::SAX::RTF;
  my $handler = new MyHandler;
  my $parser = XML::SAX::ParserFactory->parser( Handler => $handler );
  $parser->parse_file( shift @ARGV );

  package MyHandler;
  sub new {
      my $class = shift;
      my $self = {@_};
      return bless( $self, $class );
  }
  sub start_element {
      my( $self, $data ) = @_;
      print "<", $data->{Name};
      if( exists( $data->{Attributes} )) {
          my %atts = %{$data->{Attributes}};
          foreach my $att ( keys %atts ) {
              my $val = $atts{$att};
              $val =~ s/\"/&quot;/g;
              print " $att=\"$val\"";
          }
      }
      print ">";
  }
  sub end_element {
      my( $self, $data ) = @_;
      print "</", $data->{Name}, ">";
  }
  sub characters {
      my( $self, $data ) = @_;
      print $data->{Data};
  }

DESCRIPTION

This is a subclass of XML::SAX::Base which implements a SAX driver for RTF documentation. It generates XML that closely matches the structure of RTF, i.e. a set of paragraph types with text and inline tags inside.

AUTHOR

Erik Ray (eray@oreilly.com)

COPYRIGHT

Copyright 2002 Erik Ray and O'Reilly & Associates Inc.