Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: XML::Rules Parsing Order

by runrig (Abbot)
on Feb 09, 2015 at 19:51 UTC ( #1116097=note: print w/replies, xml ) Need Help??

in reply to Re: XML::Rules Parsing Order
in thread XML::Rules Parsing Order

Is there a way to always have parent_tag to be parsed first?
Doesn't look like it. But why would you want to?
E.g., maybe you're inserting parent/child records into the database, and in order to maintain referential integrity, you need to insert the parent records first. Assuming that all parent-specific data is available in the attributes of the parent tag, this would be possible with a start rule on the parent tag. That's one reason why I might want to why the OP wants to, I wouldn't know :-)

Replies are listed 'Best First'.
Re^3: XML::Rules Parsing Order
by BrowserUk (Pope) on Feb 09, 2015 at 19:59 UTC

    Okay. But if you do it when the parent tag is parsed, you have all the information from the child record available also, so you can do both in which ever order makes sense.

    But if do the parent before you parsed the child(ren), the child tag might be missing or corrupted, and you'd have then to try and back out the parent record from the DB.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
Re^3: XML::Rules Parsing Order
by feiiiiiiiiiii (Acolyte) on Feb 09, 2015 at 20:05 UTC
    Yes I need to use some content (not attributes) in the parent tag to decide if the content in the child tag should be written to the db or not. So looks like I can only store the content of the child tag in a buffer first, and then analyze it when the ending parent tag is parsed? Thanks!
      If you use one of the 'as array' rules (e.g., child_tag => 'as array'), then the child nodes get pushed to a 'buffer' for you, and will be available (as an arrayref) when parsing the parent tag.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2021-03-07 10:10 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (120 votes). Check out past polls.