i tried also while doc == true while doc = 1 while doc results dont change....
On Jun 4, 12:51 pm, lecielbleu <canal...@gmail.com> wrote: > i guess problem is while reader line because when i run basic code > below : > > while doc == true > puts reader.read_string > end > > strings never stops in the command line , it turns infinite loop. > > On Jun 4, 12:48 am, "Jeffrey L. Taylor" <r...@abluz.dyndns.org> wrote: > > > There are no <xml> header tags. I have no idea how libXML will behave. It > > isn't very tolerant of invalid input. Try adding the puts statements I've > > inserted below to find out how far it is getting. > > > Quoting lecielbleu <canal...@gmail.com>: > > > > my xml data seems like that : <Brands><Brand><Brand_id>2</ > > > Brand_id><Brand_name>HP</Brand_name></Brand> > > > and here is my codes > > > > def xml_testing > > > require'xml' > > > reader = XML::Reader.file('c:/brands.xml') > > > > stack = [] > > > while reader > > > case reader.node_type > > > when XML::Reader::TYPE_ELEMENT > > > # opening tag > > > stack << reader.name > > > puts "BEGIN #{stack.join('/')}"> > > stack.pop if reader.empty_element? > > > puts "END #{stack.join('/')}" if > > reader.empty_element?> when XML::Reader::TYPE_TEXT, > > XML::Reader::TYPE_CDATA > > > path = stack.join('/') > > > case path > > > when 'Brands/Brand/Brand_name' > > > puts reader.value # simple content > > > when XML::Reader::TYPE_END_ELEMENT > > > # closing tag > > > puts "END #{stack.join('/')}" > > > > stack.pop > > > end > > > end > > > end > > > > flash.now[:message]="brands read" > > > end --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---