Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: XML::Rules parsing inside out?

by Jenda (Abbot)
on Dec 08, 2017 at 12:03 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1205169]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2024-04-23 08:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found