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

Hi,

I'm receiving this type of xml queries from KnxWeb program (visualization web interface for home automation).

<read><objects><object id='ecl_couloir'/><object id='cur_date'/><objec +t id='cur_time'/></objects></read>

I tried XML::Simple but it gives parser error: Extra content at the end of the document.

Can I use XML::Simple for it with some proper setting ?

What would be my next choice ?

Thanks in advance,

regards,

Perl newbie-rob.

Replies are listed 'Best First'.
Re: Which XML parser for this type of xml queries
by duckyd (Hermit) on Dec 06, 2008 at 22:52 UTC
    I saved your xml to a file called example.xml and was able to use XML::Simple to parse it w/o any problem:
    $ perl -MData::Dumper -MXML::Simple -e 'print Dumper XMLin(q{example.x +ml});' $VAR1 = { 'objects' => { 'object' => { 'cur_date' => {}, 'cur_time' => {}, 'ecl_couloir' => {} } } };
    My guess is that you really do have some garbage at the end of your document - have you printed it out with, say, single quotes around it so that you'd me more likely to spot something funny? I.E.
    print "xml content: '$xml'\n";
      Thanks for the tip. I've chopped last character and now it works. But I'm still curious why is read not present in hash presentation ? It's crucial for my parsing...

      Regards,

      Rob.