I have a xml file
<?xml version="1.0" encoding="UTF-8"?>I want to display, store values like this
require “rexml/document”
include REXML
doc = Document.new File.new(“yourBill.xml”)
billerName="";billingAccountNumber="";startDate="";endDate="";openAmount="";totalCredits="";totalDebits="";
amountDue="";
root = doc.root
billerName = root.attributes[‘billerName’]
billingAccountNumber = root.attributes[‘billingAccountNumber’]
startDate = root.attributes[‘startDate’]
endDate = root.attributes[‘endDate’]
openAmount = root.attributes[‘openAmount’]
totalCredits = root.attributes[‘totalCredits’]
totalDebits = root.attributes[‘totalDebits’]
amountDue = root.attributes[‘amountDue’]
puts "Biller Name: " + billerName
puts "Acct.# " + billingAccountNumber
puts "Start Date : " + startDate
puts "End Date : " + endDate
puts "Open Amt. : " + openAmount
puts "Total Credits : " + totalCredits
puts "Total Debits : " + totalDebits
puts "Amount Due : " + amountDue
entire_details = root.elements.to_a("//bill")
puts entire_details
puts entire_details.length
puts entire_details[4].attributes[‘accountId’]
puts
entire_details[2][0].elements["//bill/ratePlans"].attributes[“totalAmount”]
I produces output like this:
Biller Name: Vikash
Acct.# 161
Start Date : 06/01/2007
End Date : 06/30/2007
Open Amt. : 0.00
Total Credits : 0.00
Total Debits : 624.00
Amount Due : 624.00
5
eb
I want to store all the values in an array or variables, please help me
out in doing this
Thanks in advance
Vikash