Slashdot Mirror


XML::Simple for Perl Developers

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."

7 of 186 comments (clear)

  1. XML::LibXML is where it's at by teknomage1 · · Score: 5, Informative

    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.

    --
    Stop intellectual property from infringing on me
    1. Re:XML::LibXML is where it's at by rvalles · · Score: 4, Informative

      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.

  2. hmm by XanC · · Score: 2, Informative

    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.

  3. Simple is not good by MarkKnopfler · · Score: 2, Informative

    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.

  4. XML data structure serialization by barnacle · · Score: 2, Informative

    This is the same approach that is built-in to the qore language http://qore.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

  5. Re:Hello, AC by chromatic · · Score: 2, Informative

    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.

  6. XSLT can't do arithmetic? WTF? by johnny99 · · Score: 2, Informative

    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() function.

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