Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7335

happymapper cannot get element

Newsgroups comp.lang.ruby
Date 2017-02-11 04:34 -0800
Message-ID <2e801ae4-8d95-4351-bdda-50b9ff864356@googlegroups.com> (permalink)
Subject happymapper cannot get element
From Sayth Renshaw <flebber.crue@gmail.com>

Show all headers | View raw


Hi

I am having a hard time working with the examples on the happymapper fork site https://github.com/dam5s/happymapper.

require 'happymapper'

My expected output
sayth@sayth-E6410 ~/race (master●)$ ruby read_race.rb            [ruby-2.4.0p0]
de
Germany
23

My current output
sayth@sayth-E6410 ~/race (master●)$ ruby read_race.rb            [ruby-2.4.0p0]
de
Germany

It's just missing I have tried many version however cannot get 23 to spit out.




xml_doc = <<EOF
<address location='home'>
  <street>Milchstrasse</street>
  <street>Another Street</street>
  <housenumber>23</housenumber>
  <postcode>26131</postcode>
  <city>Oldenburg</city>
  <country code="de">Germany</country>
</address>
EOF

class Country
  include HappyMapper

  tag 'address'
  content :housenumber, Integer

  # element :name, Integer

  tag 'country'

  attribute :code, String
  content :name, String

end

outputs = Country.parse(xml_doc)
outputs.each do |output|
  puts output.code
  puts output.name
  puts output.housenumber
end

Any ideas?

Cheers

Sayth

Back to comp.lang.ruby | Previous | Next | Find similar


Thread

happymapper cannot get element Sayth Renshaw <flebber.crue@gmail.com> - 2017-02-11 04:34 -0800

csiph-web