|Keep It Simple, Stupid|
XML::Rules parsing inside out?by bfdi533 (Friar)
|on Dec 06, 2017 at 23:52 UTC||Need Help??|
bfdi533 has asked for the
wisdom of the Perl Monks concerning the following question:
I have been scratching my head trying to figure out what is wrong with my parsing rules and I find put in some print statements in the rules and found that XML::Rules is parsing the XML "inside out". I am reading through the XML top to bottom to develop my rules and logic and find I am missing some info. Now I see why.
take the following example:
I have been attacking this (seemingly) incorrectly with rules like the following:
This does not work. value is processed before item which is processed before the outside tag so the flags get set AFTER the section has already processed the guts. I only saw this from the print statement in '_default' rule which I added out of sheer frustration.
The result is $sumvalue is equal to d1 value, $d1value = d2 value and $d2value is never set. I have been losing my mind over this.
How do I properly handle duplicate tags in different sections if I cannot flag them due to the way the XMl is processed in this inside out manner???
Update: Updated the XML to have proper wrapper.