Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^5: XML::Parser Tutorial

by Jenda (Abbot)
on Aug 24, 2008 at 12:41 UTC ( #706555=note: print w/replies, xml ) Need Help??

in reply to Re^4: XML::Parser Tutorial
in thread XML::Parser Tutorial

<tag attr="something"/> IS XML the way it was originaly designed. XML tags are not required to have content, they can very well have only attributes or just appear in the file with no additional info. Do show us the code!

As far as programmer intervention goes ... you have to intervene somewhere. Of course you can use a module that takes only the XML and gives you a maze of objects and you really do not have to set up anything FOR THIS STEP of the XML processing. But then you have to navigate the maze to get your hands on the data. The first step is easy, but it doesn't take you far.

Or you can do some work upfront to specify some rules and obtain a data structure that's already tweaked to whatever you need to do with the data later.

Or you can use a parser that just splits the XML apart and hands you the individual pieces (which is what most styles of XML::Parser do) and you have to handle all the pieces of data immediately as they are found in the file.

Which style (or a combination of styles) works best for you and the task at hand is something you have to find out. And for XML::Rules ... you can ask it to infer the base set of rules from the DTD or example XMLs. If you do that and leave the ruleset alone, you basicaly end up with the first style. Except that you end up with a HashOfHashesAndArraysOfHashes... instead of objects. But you can tweak the ruleset to skip the stuff you are not interested in, reformat the structure to simplify the searches later, change some static rules to subroutines and handle the data as soon as that particular tag with all its contents is parsed, etc.

In either case DO show us the failing code using XML::Parser! We do want to see the problem. Or at least I do. Most likely it's something you do, but if there really is a bug in the module I need to know. 'Cause XML::Rules is based on XML::Parser.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2020-09-26 02:13 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (141 votes). Check out past polls.