xml-mapping lib question?

Z

zxem

Hi all,

I got a xml looking like this.

<VolPoint Strike="10" OptionType="Rr Mkt"
Interp="1">-0.015523356673284</VolPoint>

I tried to create a ruby class for it which is used by xml-mapping
library.

class VolPoint
include XML::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!
 
Z

zxem

Hi all,

I got a xml looking like this.

<VolPoint Strike="10" OptionType="Rr Mkt"
Interp="1">-0.015523356673284</VolPoint>

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,271
Latest member
BuyAtenaLabsCBD

Latest Threads

Top