I''m new to Ruby and need to write some code to parse a variable length XML structure like the one below. In the below case, the <port> time can occur a variable number of times. I want to store each one of these port numbers into a separate database record. Also, is there anyway for Rails to automatically insert these into a relational set of models. For instance, the Address record would contain the ''host'' and then a many to many relationship to a bunch of port numbers. Are there any features or libraries to make this mapping easier when parsing? Thanks Chirag <address> <host>example.org</host> <port>1234</port> <port> 5678</port> ... <port> 6789</port> </address> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
chirag wrote:> I''m new to Ruby and need to write some code to parse a variable length > XML structure like the one below. In the below case, the <port> time > can occur a variable number of times. I want to store each one of > these port numbers into a separate database record. > > Also, is there anyway for Rails to automatically insert these into a > relational set of models. For instance, the Address record would > contain the ''host'' and then a many to many relationship to a bunch of > port numbers. Are there any features or libraries to make this mapping > easier when parsing? > > Thanks > Chirag > > <address> > <host>example.org</host> > <port>1234</port> > <port> 5678</port> > ... > <port> 6789</port> > </address>Do a Google search for REXML. It''s a standard Ruby library. It will do all the XML parsing you need. --Al Evans -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---