feiiiiiiiiiii has asked for the wisdom of the Perl Monks concerning the following question:
Hi! I recently came across a problem about XML::Rules parsing order.
Say I have some code like this
my %rules = ( _default => sub {$_[0] => trim($_[1]->{_content})}, parent_tag => sub {...}, child_tag => sub {...}, )
the structure of the xml file is like
<parent_tag> ... <child_tag> ... </child_tag> </parent_tag>
Will parent_tag or child_tag be parsed first? i.e. Does the parsing happen when a start tag is met, or when an end tag is met? I don't know why the order seemed to be quite random
Is there a way to always have parent_tag to be parsed first? Thanks!
+++++UPDATE+++++
Thanks for all the replies. You are amazing~~~
The reason why I want to parse the parent tag first is that I need to use the content (attributes) in the parent tag to decide if the content in the child tag should be store into the database. So if I prepend "^" to parent_tag, I can parse the parent tag first, but I cant get the content of the parent_tag but only its attributes, right?
So the only solution is to store in content of the child tag is some buffer, and then analyze it when the ending parent_tag is met and parsed?
Thanks again:)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Rules Parsing Order
by runrig (Abbot) on Feb 09, 2015 at 19:40 UTC | |
|
Re: XML::Rules Parsing Order
by BrowserUk (Patriarch) on Feb 09, 2015 at 19:40 UTC | |
by runrig (Abbot) on Feb 09, 2015 at 19:51 UTC | |
by BrowserUk (Patriarch) on Feb 09, 2015 at 19:59 UTC | |
by feiiiiiiiiiii (Acolyte) on Feb 09, 2015 at 20:05 UTC | |
by runrig (Abbot) on Feb 09, 2015 at 21:30 UTC | |
|
Re: XML::Rules Parsing Order
by Jenda (Abbot) on Oct 13, 2015 at 11:30 UTC |