Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: XML::Simple Output

by grantm (Parson)
on Nov 19, 2003 at 09:05 UTC ( [id://308252]=note: print w/replies, xml ) Need Help??


in reply to Re: XML::Simple Output
in thread XML::Simple Output

Why does this module require two attributes to be set in order to make output have the same structure as input?

XML::Simple is optimised for reading XML. Some of the things it does to make your life easier when it reads XML make things more difficult if you try and write XML back out again. But if you're anything like me then you read XML far more often than you write it. The two operations have very little in common so one tool is unlikely to be well suited to both.

I'd be the first to admit that the XML::Simple API is a mess. The primary reason is that it wasn't planned as a general purpose XML manipulation tool. It was designed for reading XML config files. The code to write XML back out again was added on later. If I had set out to write a tool that could round-trip XML perfectly every time then I would have ended up designing some sort of DOM-type thing and at some point I would have seen the error of my ways and given up.

I'd say this is rapidly becoming a Frequently Asked Question

Perhaps, but I'd wager that most people who are asking have not read the XML::Simple documentation sitting on their own hard drive, or the XML::Simple FAQ sitting next to it. The original poster for example had a choice of 22 options and apparently didn't even try one! The ForceArray option which would be one solution to the original question is even singled out in the documentation as one of the two most important options you need to read about before you use the module. You can lead a horse to water ...

Replies are listed 'Best First'.
Re: Re: Re: XML::Simple Output
by Cody Pendant (Prior) on Nov 19, 2003 at 20:30 UTC
    Hi, thanks for that. I think part of the problem is that baffled, frustrated people who are just getting started with XML see something called XML::Simple and think it's the answer to all their prayers. I know I did.

    Maybe I could suggest putting this one particular issue in the POD?

    And you know what? I just clicked on the link to the XML::Simple::FAQ on search.cpan.org and it's a 404...



    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print
      I think part of the problem is that baffled, frustrated people who are just getting started with XML see something called XML::Simple and think it's the answer to all their prayers.

      Hoping that something will be both simple and the "answer to all their prayers" is surely a bit naiive. Take for example LWP::Simple. It certainly provides a simple API for retrieving web-based objects but if the "answer to all your prayers" requires cookie, proxy and authentication support then you've just outgrown the simple API and you have to learn a whole new one. Similarly if/when you outgrow XML::Simple, you need to move up to something offering more fine-grained control, such as XML::LibXML.

      Maybe I could/should suggest putting this one particular issue in the POD?

      The most common complaint I get about the XML::Simple documentation is that there is too much of it. Seriously. People email me with a question that they strongly suspect is answered in the POD but there is so much POD that it's quicker to email me (or post on PM) than sit down and read it.

      But you're right, I could improve the POD's coverage of round-tripping.

      And you know what? I just clicked on the link to the XML::Simple::FAQ on search.cpan.org and it's a 404

      That is odd. If I go to the main screen for the XML::Simple distribution then the link works. But that's a little bit of a red-herring - why search the web for documentation that's already on your hard drive? Especially when the one you find on the web might be for a different version than the software you have installed

        OK I was being facetious about the "answer to all their prayers" thing.

        The 404 comes when I use search.cpan.org, find this page http://search.cpan.org/~grantm/XML-Simple-2.09/lib/XML/Simple.pm and then see this link at the bottom http://search.cpan.org/perldoc?XML%3A%3ASimple%3A%3AFAQ.

        And the FAQ isn't on my hard drive, it may or may not be on a web server someone else owns and which I don't have command-line access to. Lots of people code that way, like it or not.

        Here's a question for the ages -- why isn't XML::Simple the top hit when I search CPAN for "XML::Simple"?

        But I'm going to stop being facetious now and say thank you for responding and having written the module. It was the answer to a good 80% of my prayers, right out of the box!



        ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-16 20:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found