From: zxem Date: 2007-11-21T01:20:04+09:00 Subject: Re: xml-mapping lib question? On Nov 19, 3:49 pm, zxem wrote: > Hi all, > > I got a xml looking like this. > > Interp="1">-0.015523356673284 > > I tried to create a ruby class for it which is used byxml-mapping > library. > > class VolPoint > includeXML::Mapping > text_node :Interp, "@Interp", :default_value=>nil > text_node :Strike, "@Strike", :default_value=>nil > text_node :OptionType, "@OptionType", :default_value=>nil > text_node :VolValue, "text()", :default_value=>nil # Does not work > here > end > > But this class could not get the text from VolPoint element(last line > of code). Could anyone tell me how to get the value out of the > VolPoint? > > Cheers! I found the solution, you should write the code like this: class VolPoint includeXML::Mapping text_node :Interp, "@Interp", :default_value=>nil text_node :Strike, "@Strike", :default_value=>nil text_node :OptionType, "@OptionType", :default_value=>nil text_node :VolValue, "", :default_value=>nil end