IO::Async::XMLStream::SAXReader - Dispatch SAX events from an XML stream.
version 0.001000
use IO::Async::XMLStream::SAXReader; use IO::Async::Loop; my $loop = IO::Async::Loop->new(); my $sax = IO::Async::XMLStream::SAXReader->new( handle => $SOME_IO_HANDLE, on_start_document => sub { my ( $saxreader, @args ) = @_; ... }, on_start_element => sub { my ( $saxreader, @args ) = @_; ... }, on_end_document => sub { $loop->stop; }, ); $loop->add($sax); $loop->run();
This sub-classes IO::Async::Stream to provide a streaming SAX parser.
IO::Async::Stream
For the individual SAX events that can be listened for, see XML::SAX::Base.
SAX
XML::SAX::Base
All are prefixed with the on_ prefix as constructor arguments.
on_
Alternatively, if you already have an XML::SAX handler class you wish to reuse:
XML::SAX
use IO::Async::XMLStream::SAXReader; use IO::Async::Loop; my $loop = IO::Async::Loop->new(); my $sax = IO::Async::XMLStream::SAXReader->new( handle => $SOME_IO_HANDLE, sax_handler => YourClass->new(); on_read_eof => sub { $loop->stop; }, ); $loop->add($sax); $loop->run();
Kent Fredric <kentfredric@gmail.com>
This software is copyright (c) 2014 by Kent Fredric <kentfredric@gmail.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install IO::Async::XMLStream::SAXReader, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Async::XMLStream::SAXReader
CPAN shell
perl -MCPAN -e shell install IO::Async::XMLStream::SAXReader
For more information on module installation, please visit the detailed CPAN module installation guide.