Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: RedWolf MonkChatter

by mirod (Canon)
on Feb 28, 2001 at 14:26 UTC ( #61317=note: print w/replies, xml ) Need Help??

in reply to RedWolf MonkChatter

You should really use an XML parser (what else would you expect from me ;--). On top of the reasons given in On XML Parsing, if the format of the CB changes even slightly you will have to update your code (think about an extra attribute for each message). If you used an XML module you would have a much better chance to survive those modifications. Plus learning how to use one of the XML modules is a Good Thing (tm).

2 more points: I don't find XML::Simple difficult to install. I would not use the xml bundle. Either get XML::Parser 2.27 which comes with expat or get XML::Parser 2.30 and expat from and compile it, install XML::Parser get XML::Simple, install it et voila!

Then I am not sure I would want to use XML::Simple for the CB. The problem is that it will create an unordered list of messages, that you then have to order on the time field. I would probably use XML::PYX to get the messages in the right order. OK, I'm lying I would use XML::Twig, but maybe starting with PYX would be easier.

Update: epoptai below is right, XML::Simple actually stores the messages in the proper order. I would have sworn I saw them messed up the other day. I would still try another method, if only to get a break from the ubiquitous XML::Simple ;--)

Here is how XML::PYX outputs each message in the CB:

(message Aauthor strredwolf Atime 20010228082806 -\n -OK, I'm convinced, I will use XML::PYX )message

Easy to process isn't it?

Replies are listed 'Best First'.
Re: Re: RedWolf MonkChatter
by epoptai (Curate) on Mar 01, 2001 at 11:08 UTC
    I am not sure I would want to use XML::Simple for the CB. The problem is that it will create an unordered list of messages, that you then have to order on the time field.

    No such problem mirod. I'm using XML::Simple (v2.27) to parse the CB and can assure you that the messages come out of the parser in the correct order.

Re: Re: RedWolf MonkChatter
by strredwolf (Chaplain) on Mar 01, 2001 at 06:08 UTC
    Does XML::PYX and XML::Twig need XML::Parser(and thus expat)? I'm trying to get away from having folks need to compile that (which kinda breaks compiling though CPAN::shell).

    But then, XML::PYX seems to use a similar engine that I'm using now.


      All of the XML processing modules on CPAN are based on expat, including XML::Parser, XML::PYX, XML::Simple, XML::Twig and many more.

      I fail to see why it is such a problem. Yes it means you cannot install directly using CPAN. But it installs very easily under Unix and once again XML::Parser comes with Activestate's Windows port. I know CPAN is extremelly convenient but it is not the only valid method to install modules.

      If you want to do any serious XML processing you really need a proper parser. Using regexps is false laziness. It is akin to not using strict: good for a quick hack but a no-no for anything serious.

      Incidentally there are good reasons why expat is not bundled with XML::Parser anymore. It is used by other applications, Apache for example and bundling it lead to incompatibilities between the different versions and problems building them.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://61317]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2022-08-09 16:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found