PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > xml-mapping lib question?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
xml-mapping lib question?

Réponse
 
LinkBack Outils de la discussion
Vieux 19/11/2007, 16h49   #1
zxem
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut xml-mapping lib question?

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!
  Réponse avec citation
Vieux 20/11/2007, 17h17   #2
zxem
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: xml-mapping lib question?

On Nov 19, 3:49 pm, zxem <david.z...@gmail.com> wrote:
> 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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h43.


Édité par : vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16603 seconds with 10 queries