Say I have the following Feedjira nested parser subclasses. How can I access the xml for the Trunk, Branch, and Leaf classes so I can log/save it in the case of an error? Preferably just the xml for the parsed element, but I'd take the xml for the whole Trunk in the case of a 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 do |n| branch = branches[ n ].createModel branch.trunk_id = trunk.id branch.save! end rescue StandardError => e # log the error and the xml for this 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 do |n| leaf = leaves[ n ].createModel leaf.branch_id = branch.id leaf.save! end rescue StandardError => e # log the error and the xml for this 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 the error and the xml for this leaf element. HOW?? ::Rails.logger.error "Parse Error, xml = #{ xml }" end end end endend