xml parsing error in perl


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 05-30-2007
xml parsing error in perl

******************PERL VERSION************************
This is perl, v5.8.1 built for i386-linux-thread-multi

ERROR!!!!---Undefined subroutine &main::start called at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/XML/Parser/Expat.pm line 469.

*********************PERL CODE************************
# include package
use XML::Parser;
# initialize parser
$xp = new XML::Parser;
# set callback functions
$xp->setHandlers(Start => \&start, END => \&end, Char => \&cdata);
# parse XML
$xp->parsefile("page1.xml");

************************XML FILE*********************
<?xml version="1.0"?>
<library>
<book>
<title>Dreamcatcher</title>
<author>Stephen King</author>
<genre>Horror</genre>
<pages>899</pages>
<price>23.99</price>
<rating>5</rating>
</book>
</library>


Plz remove the error if possible....
# 2  
Old 05-30-2007
Quote:
Originally Posted by bishweshwar
ERROR!!!!---Undefined subroutine &main::start called at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/XML/Parser/Expat.pm line 469.

*********************PERL CODE************************
# include package
use XML::Parser;
# initialize parser
$xp = new XML::Parser;
# set callback functions
$xp->setHandlers(Start => \&start, END => \&end, Char => \&cdata);
# parse XML
$xp->parsefile("page1.xml");
But where are the start(), end() and cdata() subroutines? Are you sure you have defined them in your code? As you are trying to pass reference to those to XML::Parser. If they are not defined, XML::Parser on dereferencing them will cause the error. It's not even a parsing error so there is nothing to do with your XML file.

In fact you can repeat the error with something as simple as

Code:
root@xxxxxx:~ # perl -w -e '$a = \&xxxx; &$a'
Undefined subroutine &main::xxxx called at -e line 1.

Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
XML parsing r_t_1601 Shell Programming and Scripting 8 10-24-2017 03:50 AM
XML Parsing : asavaliya Shell Programming and Scripting 3 03-16-2014 10:13 PM
Xsltproc showing error in parsing xml...help required alpha_1 Shell Programming and Scripting 2 03-12-2014 01:43 PM
XML parsing vivek d r Shell Programming and Scripting 12 03-05-2013 09:20 AM
XML: parsing of the Google contacts XML file ripat Shell Programming and Scripting 9 12-25-2012 10:07 AM
Help in parsing XML output file in perl. rkrish Shell Programming and Scripting 7 12-19-2012 02:13 AM
parsing XML result by using perl? tiger2000 Shell Programming and Scripting 2 08-15-2012 12:12 PM
XML Parsing manas_ranjan UNIX for Advanced & Expert Users 6 02-24-2012 09:20 AM
XML parsing LavanyaP Shell Programming and Scripting 6 06-16-2011 09:29 AM
Bash XML Parsing using Perl XPath jfmorales Shell Programming and Scripting 4 01-06-2011 02:07 PM
Random XML Parsing - using Perl ricksj Shell Programming and Scripting 4 09-09-2010 09:23 PM
XML Parsing Mavericc Shell Programming and Scripting 4 09-16-2008 01:01 PM
Perl parsing compared to Ksh parsing popeye Shell Programming and Scripting 1 08-06-2008 10:46 PM
parsing xml walnut Shell Programming and Scripting 1 02-21-2006 04:32 AM
XML parsing handak9 Programming 1 11-01-2004 07:13 PM