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

Hi all, dear Monks.

I'm trying to create a client/server application relying on a big data structure that has to be sent from one peer to another. I've tried to work out a solution using XML::Simple and XML::Dumper. However, there have been some issues with both of them and I feel overwhelmed already; therefore I am asking for your wisdom and guidance :P.

I guess the problem here are the encodings. I need support for ISO-8859-1 characters; however, the first doesn't seem to support them, and neither does the latter. (ps, apart from that, XML::Dumper::xml2pl doesn't seem to work, is that just me or a bug in the module :?)

Then, while checking the Data::DumpXML manpage, I found the following statement:

Class names with 8-bit characters will be dumped as Latin-1, but converted to UTF-8 when restored by the Data::DumpXML::Parser.

Which I guess renders this module also unusable for my purposes. Do you know of any other nice way to do the right thing (i.e. converting a hash of hashes into XML and then to a struct again) with properly-encoded XML, and, if possible, using a single module? (note: tr///ing is not acceptable ;-))

Thanks a lot for your help, and happy new year :P

Replies are listed 'Best First'.
Re: XML encoding problems...
by mirod (Canon) on Jan 02, 2002 at 09:52 UTC

    Look at Text::Iconv for all your encoding conversion needs. You could even just use iconv to convert UTF-8 to ISO-8859-1 when needed.

      I think I got over the issue by using the apparently undocumented parse() function from Data::DumpXML::Parser (at least, the manpage only talks about parsefile(), leaving clueless newbies like me slightly... f.. er, lost), as crazyinsomniac mentioned. Still have to check if it does what I expect, (update: it does :P) but it's good to have that Text::Iconv thing back there, just in case.

      Therefore, thanks a lot! :-)