Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML::Parser problem

Status
Not open for further replies.

redgenie

Programmer
Aug 10, 2000
36
GB
I am having some problems with the XML::parser module. It is returning an error when passed some valid xml in the form of a string. The error it returns is:

No element found at line 1, column 0 byte -1

This seems to suggest that the string is empty although if I print the string immediately prior to trying to parse it, the contents are fine.

Here is a copy of the code:
use XML::parser;

my $sourceXML=&quot;<h><j>whatever</j></h>&quot;;

my $parser = new XML::parser();

$parser->setHandlers( Start => \&hdl_start,
End => \&hdl_end,
Char => \&hdl_char
);

#=- Parse the document
print &quot;Trying to parse:\n $sourceXML \n&quot;;
$parser->parse($sourceXML);

print &quot;Completed successfully&quot;;
exit;



##====-- The Event Handlers used during parsing --====##

#=-- Tag Opened Event (this is called when a tag is first opened)
sub hdl_start{
}

#=-- Tag Closed Event (this is called when a tag is closed)
sub hdl_end{
}

#=-- Tag Data Event (this is called when data within tags is being processed)
sub hdl_char {
}


The exact same code works perfectly on another machine.

Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top