XML-Smart
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/XML/Smart/HTMLParser.pm view on Meta::CPAN
#############################################################################
## Name: HTMLParser.pm
## Purpose: XML::Smart::HTMLParser
## Author: Graciliano M. P.
## Modified by: Harish Madabushi
## Created: 29/05/2003
## RCS-ID:
## Copyright: (c) 2003 Graciliano M. P.
## Licence: This program is free software; you can redistribute it and/or
## modify it under the same terms as Perl itself
#############################################################################
package XML::Smart::HTMLParser ;
use 5.006 ;
use strict ;
use warnings ;
use XML::Smart::Shared qw( _unset_sig_warn _reset_sig_warn ) ;
our ($VERSION , @ISA) ;
$VERSION = '1.12' ;
#######
# NEW #
#######
sub new {
my $this = shift ;
my $class = ref($this) || $this ;
return $this if ref $this ;
$this = bless {} => $class ;
_unset_sig_warn() ;
my %args = @_ ;
_reset_sig_warn() ;
$this->setHandlers(%args) ;
$this->{NOENTITY} = 1 ;
return $this ;
}
###############
# SETHANDLERS #
###############
sub setHandlers {
my $this = shift ;
_unset_sig_warn() ;
my %args = @_;
_reset_sig_warn() ;
$this->{Init} = $args{Init} || sub{} ;
$this->{Start} = $args{Start} || sub{} ;
$this->{Char} = $args{Char} || sub{} ;
$this->{End} = $args{End} || sub{} ;
$this->{Final} = $args{Final} || sub{} ;
return( 1 ) ;
}
#########
# PARSE #
#########
sub parse {
my $this = shift ;
my $data = shift ;
$data =~ s/\r\n?/\n/gs ;
$data =~ s/^\s*<\?xml.*?>//gsi ;
my @parsed ;
while( $data =~ /(.*?)<(.*?)>/gsi ) {
my $cont = $1 ;
my $markup = $2 ;
my ( $more_q , @args ) = &parse_tag( $markup ) ;
while( $more_q ) {
my $more ;
( $more ) = ( $data =~ /\G(.*?)>/s ) ;
pos( $data ) += length( $more ) + 1 ;
$markup = $markup.'>'.$more ;
( $more_q , @args ) = &parse_tag( $markup ) ;
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.285 second using v1.00-cache-2.02-grep-82fe00e-cpan-48ebf85a1963 )