ub3rFrank has asked for the wisdom of the Perl Monks concerning the following question:

Im running into some trouble using the XML::Parser module. I'm able to successfully parse xml output from a socket but I recieve an error when I try to parse an xml file. Here is my code segment for opening the parser and trying to parse the file:

my $configReader = new XML::Parser;</br> $configReader->setHandlers ( Start => \&readConfig, End => \&HandleEnd, Char => \&HandleChar );</br> $configReader->parsefile( $configFile );

I reiece the following error:
unclosed token at line 1, column 0, byte 0 at
H:/SwDev/Rdriver/Perl.5.8/lib/XML/Parser.pm line 187

it seems like there is something wrong with the module itself from the error but I want to make sure. I also recieve the same exact error when I tried to read in an XML file using XML::Simple 's XMLin utility. Can anyone out there help me? Thanks.

Replies are listed 'Best First'.
Re: using XML::Parser
by dragonchild (Archbishop) on Apr 29, 2008 at 14:31 UTC
    Sounds like you have malformed XML. I'd look a bit harder at your file, particularly for hidden characters at the beginning of the file.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      Thanks. It turns out I was missing a second ? in my xml header. Appreciate the help.

        You could tidy up your HTML while you are at it. ;)

        </br> is not HTML. You could use <br/> or <br>.


        Perl is environmentally friendly - it saves trees