Erik Ray > XML-SAX-RTF-0.1 > XML::SAX::RTF

Download:
XML-SAX-RTF-0.1.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.1   Source   Latest Release: XML-SAX-RTF-0.2

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.

syntax highlighting: