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

Re: XML::Rules parsing inside out?

by Jenda (Abbot)
on Dec 08, 2017 at 12:03 UTC ( #1205169=note: print w/replies, xml ) Need Help??


in reply to XML::Rules parsing inside out?

Yes, the normal rules work inside out. They are not meant to set global variables, they are supposed to extract, massage and return data. You should only change the global state once you are done with the branch. For example if the XML contains a list of articles, then the rules for the inner tags will massage the data into a convenient format and the rule for the articles will insert the accumulated data into the database.

XML::Rules is not a normal event based parser, one that would fire events at you and expect you to take care of any bookkeeping.

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

Replies are listed 'Best First'.
Re^2: XML::Rules parsing inside out?
by runrig (Abbot) on Dec 14, 2017 at 16:54 UTC
    XML::Rules is not a normal event based parser, one that would fire events at you and expect you to take care of any bookkeeping.
    Depending on the XML and what I'm trying to do, sometimes I find it easier to use XML::Rules as a semi-event based parser by leveraging the start rules and setting global variables.

      Whatever works. :-)

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2021-03-03 00:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (67 votes). Check out past polls.

    Notices?