Home Declaring XML Tags in Ruby
Reply: 1

Declaring XML Tags in Ruby

George123
1#
George123 Published in 2017-12-06 11:02:41Z

I am using Ruby to pull information from an excel sheet and with this information produce an xml file. I need to produce this in Ruby:

What I want:

<Betrag waehrung="EUR">150000</Betrag>

What I have:

<Betrag waehrung ="EUR"/>

I am currently trying xml.Betrag "Waehrung": "Eur" the Betrag has a row Identifier of "#{row[13]}" which is where it can be found on the excel sheet I am using. I have tried: xml.Betrag "Waehrung": ("Eur"), ("#{row[13]}") with no success, could you please advise?

Muhammad Abdullah
2#
Muhammad Abdullah Reply to 2017-12-06 11:35:03Z
require 'nokogiri'
builder = Nokogiri::XML::Builder.new do |xml|
  xml.Betrag(waehrung: 'EUR') do  |e|
    e << '150000'
  end
end
puts builder.to_xml


=>
<?xml version="1.0"?>
<Betrag waehrung="EUR">150000</Betrag>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305724 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO