in reply to Separate a single xml into mulitple XML using perl

XML::Simple is designed for simple XML documents. It is not designed to be a simple to use XML parser. Trying to do "interesting" stuff with XML::Simple is a recipe for misery. In the long run (say in an hour) converting to something like XML::Twig will be less tedious and make your life much happier than persisting in trying to hammer XML::Simple into shape for a job it wasn't designed for.

Seriously, have a serious crack at using XML::Twig. If you haven't made solid progress in an hour come back for some tips.

Premature optimization is the root of all job security
  • Comment on Re: Separate a single xml into mulitple XML using perl

Replies are listed 'Best First'.
Re^2: Separate a single xml into mulitple XML using perl
by gr.d (Novice) on Jan 06, 2016 at 07:22 UTC

    I do find XML::Twig pretty easier, My superiors are so adamant on sticking to XML::Simple, I don't get a say in that. That's the reason as of now I'm sticking with XML::Simple. But can anything be done on the code I posted? Really appreciate the help

      My superiors are so adamant on sticking to XML::Simple
      Perhaps you should try to have them read this: XML::Simple needs to go!

      See Simpler than XML::Simple

      If you have XML::Simple, you most likely also have XML::Parser & XML::Parser::Expat. XML::Rules is a plain Perl module on top of XML::Parser::Expat, so you don't really need to build and install it into the Perl directories, you can use it as a module you write yourself and copy it with the rest of your app/scripts.

      I believe you can do the same with XML::Twig.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

      But can anything be done on the code I posted?

      Yes, it can be ignored :)

      It doesn't use XML::Simple, its parsing xml by hand

      The xml file you posted isn't valid