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


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.