rellaboyina has asked for the wisdom of the Perl Monks concerning the following question:
sub parse { my $self = shift; my $arg = shift; my @expat_options = (); my ($key, $val); while (($key, $val) = each %{$self}) { push(@expat_options, $key, $val) unless exists $self->{Non_Expat_Options}->{$key}; } my $expat = new XML::Parser::Expat(@expat_options, @_); my %handlers = %{$self->{Handlers}}; my $init = delete $handlers{Init}; my $final = delete $handlers{Final}; $expat->setHandlers(%handlers); if ($self->{Base}) { $expat->base($self->{Base}); } &$init($expat) if defined($init); my @result = (); my $result; eval { $result = $expat->parse($arg); }; my $err = $@; if ($err) { $expat->release; die $err; } if ($result and defined($final)) { if (wantarray) { @result = &$final($expat); } else { $result = &$final($expat); } } $expat->release; return unless defined wantarray; return wantarray ? @result : $result; }
<record> <source-app >ABC</source-app> <ref-type>6</ref-type> <contributors> <authors> <author> <style face="normal" font="default" size="100%">Dvoøák, Petr +</style> </author> </authors> </contributors> <titles> <title> <style face="normal" font="default" size="100%">Systematická te +ologie I : ø*mskokatolická perspektiva</style> </title> </titles> <pages> <style>285 s.</style> </pages> <edition> <style>1. vyd.</style> </edition> <keywords> <keyword> <style>uèen* katolické c*rkve</style> </keyword> </keywords> <dates> <year> <style>1996</style> </year> </dates> <pub-location> <style>Brno
Praha</style> </pub-location> <publisher> <style>Centrum pro studium demokracie a kultury ;
Èeská køe +sanská akademie</style> </publisher> <notes> <style>uspoøádali Francis S. Fiorenza a John P. Galvin ; [z angl +iètiny pøeložili Petr Dvoøák ... et al.]
20 cm
Pozn.
 +;Pozn. o autorech traktátù
Zkratky
Bibliogr.
Odkazy na +lit.
Jmenný a vìcný rejstø*k</style> </notes> </record>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help in parsing the special characters using XML::Parser
by mirod (Canon) on Nov 19, 2007 at 09:51 UTC | |
by Anonymous Monk on Oct 29, 2008 at 00:51 UTC | |
|
Re: Need help in parsing the special characters using XML::Parser
by siva kumar (Pilgrim) on Nov 19, 2007 at 08:58 UTC |