ruby on rails - How to access xml in Feedjira parser classes -
say have following feedjira nested parser subclasses. how can access xml trunk, branch, , leaf classes can log/save in case of error? preferably xml parsed element, i'd take xml whole trunk in case of branch or leaf.
thanks!
module feedjira module parser class trunk include saxmachine include feedentryutilities element :trunkname elements :branch, as: :branches, class: branch def createmodel begin trunk = activerecordtrunk.create( name: trunkname ) branches.each_index |n| branch = branches[ n ].createmodel branch.trunk_id = trunk.id branch.save! end rescue standarderror => e # log error , xml trunk element. how?? ::rails.logger.error "parse error, xml = #{ xml }" end end end class branch include saxmachine include feedentryutilities element :branchname elements :leaf, as: :leaves, class: leaf def createmodel begin trunk = activerecordbranch.create( name: branchname ) leaves.each_index |n| leaf = leaves[ n ].createmodel leaf.branch_id = branch.id leaf.save! end rescue standarderror => e # log error , xml branch element. how?? ::rails.logger.error "parse error, xml = #{ xml }" end end end class leaf include saxmachine include feedentryutilities element :leafname def createmodel begin leaf = activerecordleaf.create( name: leafname ) rescue standarderror => e # log error , xml leaf element. how?? ::rails.logger.error "parse error, xml = #{ xml }" end end end end end
Comments
Post a Comment