REXML - Storing a certain element

neGrroEbanooto

New Member
This is my XML file:\[code\]<performance_summary_response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://cakemarketing.com/affiliates/api/2/"> <success>true</success> <row_count>7</row_count> <periods> <period> <date_range>12 Months</date_range> <current_revenue>22369.7000</current_revenue> <previous_revenue>3664.1000</previous_revenue> <currency_symbol>$</currency_symbol> </period> </periods></performance_summary_response>\[/code\]I'm using REXML to extract the current_revenue element where the date_range is 12 months. I've got the following code:\[code\]period = ['12 Months']data.elements.each('//date_range/..') do |parent| if (period.include? parent.elements['date_range/text()'].to_s) puts parent.elements['current_revenue'] endend\[/code\]This prints 22369.7000, however, I'm unable to extract just the numerical value and assign this to a variable. How could I possibly go about doing that?
 
Back
Top