Forgot your password?
typodupeerror
Perl Programming

XML::Simple for Perl Developers 186

An anonymous reader writes "XML has become pervasive in the computing world and is buried more and more deeply into modern applications and operating systems. It's imperative for the Perl programmer to develop a good understanding of how to use it. In a surprisingly large number of cases, you only need one tool to integrate XML into a Perl application, XML::Simple. This article tells you where to get it, how to use it, and where to go next."
This discussion has been archived. No new comments can be posted.

XML::Simple for Perl Developers

Comments Filter:
  • by teknomage1 ( 854522 ) on Saturday February 03, 2007 @09:12PM (#17877786) Homepage
    XML::LibXML is where it's at, it is a) quite a bit faster and b) has a sensible interfce rather than giving you useless empty hashrefs in the middle of a tree.
  • hmm (Score:3, Informative)

    by XanC ( 644172 ) on Saturday February 03, 2007 @10:17PM (#17878110)
    It only claims to support a subset of XML, and of course it is called "Tiny", so I guess I can understand not supporting CDATA or attributes (...maybe). But for a ">" in a CDATA block to cause it to fail? It doesn't seem very useful.
  • Simple is not good (Score:2, Informative)

    by MarkKnopfler ( 472229 ) on Sunday February 04, 2007 @01:38AM (#17879096)
    In my personal experience, Simple is probably the worst implementation of an XML parser in perl. For a simple implementation, I have found Twig to be much more useful, sensible and fast.
  • by barnacle ( 522370 ) on Sunday February 04, 2007 @03:35AM (#17879494) Homepage
    This is the same approach that is built-in to the qore language http://qore.sourceforge.net/ [sourceforge.net].

    It makes it really easy to manipulate data in XML format.

    However, qore supports deserialization of mixed text and data and multiple out-of order elements, XML attributes (imagine parsing a docbook file for example), as well as serialization (conversion of a qore data structure to an XML string) with the same features.

    The same limitations regarding streaming input and very large files affect this approach, but in all other common cases, it makes it really remarkably easy to manipulate and create data in XML format using this approach.

    (Qore also supports JSON with the same approach -- serialization and deserialization between JSON strings and qore data structures...)

    thanks,
    David

  • by rvalles ( 649635 ) on Sunday February 04, 2007 @03:42AM (#17879518)
    I agree completely. I've used both recently (and XML::Xpath) and XML::LibXML is much more powerful and sane, while at the same time it is about as easy to learn. There's the added advantages that being just LibXML bindings what's learned is useful in other programming languages, and that nodes are referred using Xpath, which is a really powerful and useful W3C standard that, again, is worth learning.
  • Re:Hello, AC (Score:2, Informative)

    by chromatic ( 9471 ) on Sunday February 04, 2007 @03:45AM (#17879528) Homepage

    What I find annoying is that core language features are changing operators for no reason other than to change operators.

    The Apocalypses and Synopses (which somehow you managed to quote without reading the surrounding context) explain the reasons for the changes.

  • by johnny99 ( 45334 ) on Sunday February 04, 2007 @04:16AM (#17879602)
    The author of that article says you'll want to use the magic of perl and XML::Simple because "XSLT can't do arithmetic" and proceeds to do magical things like increase numbers by 20%.

    That's just ... bizarre. Of course you can do that with XSLT! <xsl:value-of select="whatever * 1.2">

    Then he formats a number -- because XSLT, of course, doesn't have a format-number() [w3schools.com] function.

    Next article -- why you should commute to work in an airplane because, as everyone knows, cars can't turn corners.

The trouble with doing something right the first time is that nobody appreciates how difficult it was.

Working...