http://qs321.pair.com?node_id=737842


in reply to Re^3: Why oh why is working with XML so bloomin' difficult in Perl?
in thread Modified title: The structures created by many of the XML parsers in Perl appear unnecessarily deep in levels...

Good points. As Jeffa pointed out, it isn't just Perl that can have complex structures (hashes of hashes, etc) created from the XML Parsers. What is the frustrating part is that in several of the XML parser modules, the structures can become unnecessarily complex. Given the unknown data coming in, most of the parsers create the memory structures in a generic way. Not a bad thing, it just tends be cumbersome.

One problem that can arise is that the information you are looking for may not be at a consistent location within the structure which would eliminate any XML Path tools. If the data is properly tagged, then you can use rules or similar based tools. These were mentioned in earlier replies so I'm not going to rehash them.

How is this the fault of Perl? It's not. Perl, itself, knows nothing about XML. The wide variety of XML parsers within CPAN does give us a clue that the problem is really with how flexible XML can be and how some XML data sources can really make parsing it very difficult. The XML parsers do their best at parsing it but there is no best XML parser module for the majority of the XML data sources.. in some simplistic cases, such as Flickr's REST web service, XML::Simple works just fine and produces data structures that are well suited for the simple XML data. In others..

Is this a bit more clear?

The title is now "Modified title: The structures created by many of the XML parsers in Perl appear unnecessarily deep in levels..." which I hope is a bit less inflammatory. Otherwise, we'll have to get a bucket full of valium for some perlmonks ;-) (Just teasing)

Jason L. Froebe

Blog, Tech Blog