Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Why oh why is working with XML so bloomin' difficult in Perl?

by Your Mother (Archbishop)
on Jan 18, 2009 at 07:46 UTC ( [id://737124]=note: print w/replies, xml ) Need Help??


in reply to Modified title: The structures created by many of the XML parsers in Perl appear unnecessarily deep in levels...

Just say no. It's XML. Treat it so. Use XML::LibXML. It's got a learning curve but it repays in other areas like JS and the DOM. It's worth it to go native.

  • Comment on Re: Why oh why is working with XML so bloomin' difficult in Perl?

Replies are listed 'Best First'.
Re^2: Why oh why is working with XML so bloomin' difficult in Perl?
by Jenda (Abbot) on Jan 18, 2009 at 14:35 UTC

    Standardized ne Native. Using a language agnostic standard can help if you work with several languages, but it tends to come for a price. The standard can only use the common parts of the languages. Which means sometimes it feels unnatural and sometimes it's more complicated than it could be. "go native" is just hype. Go with the standard if it makes sense to you, use a (language) specific solution if it makes better sense.

      I think we have different ideas of what "hype" means. :) I resisted going to libxml for a long time and I wish someone had told me several years ago how much more productive it would make me if I'd just break down and learn its interface. My enthusiasm for the kit it not hype. It's enthusiasm for the kit.

      I think Twig is nice too, so nothing against it, but XML::Simple and similar packages floating about are a dead end hidden by several blind corners and only the most trivial, static or non-production, cases should go there. The knowledge and skill gained from wrangling it is largely wasted as it transfers nowhere other than drafting for spaghetti factories.

      Update: Oh, I neglected to consider XML::Rules, etc, which is where I think we have a disconnect since I believe you wrote it. I haven't had a chance to use it and have no opinion. I certainly wasn't comparing it to XML::Simple above. It might be great and certainly worth looking at for the OP if starting from scratch on a particular problem.

Re^2: Why oh why is working with XML so bloomin' difficult in Perl?
by admiral_grinder (Pilgrim) on Jan 19, 2009 at 19:22 UTC
    I agree here, but I'll add that the time spent learning XML::LibXML will easily made up at run time. XML::Twig is great if you need a pure Perl module, but XML::LibXML will produces results much quicker during run time and isn't as memory heavy.

      XML::Twig is great if you need a pure Perl module, but XML::LibXML will produces results much quicker

      XML::Twig is no more Pure Perl than XML::LibXML. Both use C libraries to perform the parsing. It's possible that XML::LibXML is faster, but it's not related to the choice of programming language.

      XML::LibXML [...] isn't as memory heavy.

      That's an odd thing to say. The whole idea of XML::Twig is to keep nothing in memory that doesn't need to be, whereas XML::LibXML keeps the whole document in memory.

        I stand corrected. It has been a while since I installed either, but XML::Twig is a bit easier to install than XML::LibXML.

        I can't agree with your view on the memory aspect. While XML::Twig may to keep nothing in memory, it does get pretty leaky. Then again, It has been a while, and not the latest version.

        Speed wise though LibXML is much faster than Twig. I had to switch our app from Twig to LibXML because documents in Twig were taking close to 5 seconds each, but LibXML was .05 seconds.

      XML::Twig is great if you need a pure Perl module, but XML::LibXML will produces results much quicker

      XML::Twig is no more Pure Perl than XML::LibXML. Both use C libraries to perform the parsing. It's possible that's XML::LibXML is faster, but it's got nothing to do with language selection.

      XML::LibXML [...] isn't as memory heavy.

      The whole idea of XML::Twig is to keep nothing in memory that doesn't need to be, whereas XML::LibXML keeps the whole document in memory.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found