Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^5: Loading a Local XML File

by poj (Abbot)
on Aug 27, 2019 at 15:45 UTC ( [id://11105129]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Loading a Local XML File
in thread Loading a Local XML File

You need to write the handler subroutines. What are you trying to extract from the XML ? Consider using XML::Twig

#!/perl/bin/perl use strict; use warnings; use XML::Parser; printf "OS %s Perl %s XML::Parser %s\n",$^O,$^V,$XML::Parser::VERSION; my $parser = new XML::Parser ( Handlers => { # Creates our parser object Start => \&hdl_start, End => \&hdl_end, Char => \&hdl_char, Default => \&hdl_def, } ); $parser->parsefile('sample_xml.xml'); my $str; sub hdl_start { $str = ''; }; sub hdl_end { my ($p, $elt) = @_; print "$elt = $str\n" if $elt eq 'parameter'; }; sub hdl_char { $str .= $_[1]; }; sub hdl_def {};
poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11105129]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-18 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found