xml parsing error in perl


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users xml parsing error in perl
# 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 Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Xsltproc showing error in parsing xml...help required

I need to parse text between xml tags using xsltproc. It seems the easiest way. Here the Input file looks like <?xml version="1.0" ?> - <tag:ROOT xmlns:as="http://some.org/some.xsd" xmlns:tag="http://www.tag.org/schemas" xmlns:xs="http://some.org/"> - <tag:L1> - <tag:L2> - <tag:L3> ... (2 Replies)
Discussion started by: alpha_1
2 Replies

2. Shell Programming and Scripting

XML: parsing of the Google contacts XML file

I am trying to parse the XML Google contact file using tools like xmllint and I even dived into the XSL Style Sheets using xsltproc but I get nowhere. I can not supply any sample file as it contains private data but you can download your own contacts using this script: #!/bin/sh # imports... (9 Replies)
Discussion started by: ripat
9 Replies

3. Shell Programming and Scripting

Help in parsing XML output file in perl.

Hi I have an XML output like : <?xml version="1.0" encoding="ISO-8859-1" ?> - <envelope> - <body> - <outputGetUsageSummary> - <usgSumm rerateDone="5"> - <usageAccum accumId="269" accumCaptn="VD_DP_AR" inclUnits="9999999.00" inclUnitsUsed="0.00" shared="false" pooled="false"... (7 Replies)
Discussion started by: rkrish
7 Replies

4. Shell Programming and Scripting

parsing XML result by using perl?

for some reasons, i need to parse the XML result by using perl. for instance, this is a sample XML result: <Response> <status>success</status> <answer>AAA::AAA</answer> <answer>BBB::BBB</answer> </Response> then i can use this way : my @output = (); foreach my $parts (@all) ##@all... (2 Replies)
Discussion started by: tiger2000
2 Replies

5. Shell Programming and Scripting

Parsing XML

I am trying to parse an xml file and trying to grab certain values and inserting them into database table. I have the following xml that I am parsing: <dd:service name="locator" link="false"> <dd:activation mode="manual" /> <dd:run mode="direct_persistent" proxified="false" managed="true"... (7 Replies)
Discussion started by: $criptKid617
7 Replies

6. Shell Programming and Scripting

Parsing XML

Learned People, Hello ! Till today, for the most part, all of the tricky questions/situations that I encountered were already posted by other folks and all I had to do was peruse through these one at a time and I could find some sort of an answer and all I had to do was add some minor tweaks... (5 Replies)
Discussion started by: ManoharMa
5 Replies

7. Shell Programming and Scripting

Bash XML Parsing using Perl XPath

I have a bash script that needs to read input from an XML file, which includes varying numbers of a certain type of child node. I want to be able to iterate through all the child nodes of a given parent. I installed the Perl XML-XPath package from search.cpan.org. Once it's installed, from bash,... (4 Replies)
Discussion started by: jfmorales
4 Replies

8. Shell Programming and Scripting

Random XML Parsing - using Perl

Given the XML: <?xml version="1.0" encoding="UTF-8"?> <reference> <refbody> <section> <p> <ul> <li><xref href="file1.dita#anchor" /></li> <li><xref href="file2.dita#anchor" /></li> </ul> </p> </section> <section> <p> <xref href="file3.dita#anchor" /> </p> <p> <xref... (4 Replies)
Discussion started by: ricksj
4 Replies

9. Shell Programming and Scripting

Perl parsing compared to Ksh parsing

#! /usr/local/bin/perl -w $ip = "$ARGV"; $rw = "$ARGV"; $snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw"; $snmpw = "/usr/local/bin/snmpwalk -Os -c $rw"; $syst=`$snmpg $ip system sysName sysObjectID`; sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies

10. Shell Programming and Scripting

parsing xml

I want to use wget comment to parse an xml parse that exist in an online website. How can I connect it using shell script through Unix and how can I parse it?? (1 Reply)
Discussion started by: walnut
1 Replies
Login or Register to Ask a Question