Hi All, I have installed "libxml-ruby" gem on my ruby instllation. while trying to create xml document with ruby progam in Rad Rails am getting error like "uninitialized constant XML::Document (NameError)" do i need to config any thing else in environment.rb file Thanks in advance Chinna. -- Posted via http://www.ruby-forum.com/.
Hi In config/environment.rb you have to add config.gem "libxml-ruby", :lib=>"xml/libxml", :version=>"=versionnumber" Sijo -- Posted via http://www.ruby-forum.com/.
Sijo k g wrote:> Hi > > In config/environment.rb you have to add > > config.gem "libxml-ruby", :lib=>"xml/libxml", :version=>"=versionnumber" > > > SijoHi Sijo, Thank you very much for your quick response. I have updated config/environment.rb file ad u suggested as follows config.gem "libxml-ruby", :lib=>"xml/libxml", :version=>"1.1.3" . but am getting same error. Are there any things am missing, can you pls suggest me. Regards Chinna. -- Posted via http://www.ruby-forum.com/.
Hi Restart the server after added this. And even if the problem exists, paste the code Sijo -- Posted via http://www.ruby-forum.com/.
Hi Sijo, here is the code can you suggest me where is going wrong.More over i am not working on the server. I am just creating simple example on RadRails IDE. require ''xml/libxml'' doc = XML::Document.new() doc.root = XML::Node.new(''root_node'') doc.root << XML::Node.new(''elem1'') puts doc Chinna. -- Posted via http://www.ruby-forum.com/.
Hi> I am just creating simple example on RadRails IDE.This I didnot understand. Anyway if you are working from konsole before require ''xml/libxml'' you have to write require ''rubygems'' Try this from konsole Sijo -- Posted via http://www.ruby-forum.com/.
Hi Sijo, What i mean is, i created a simple ruby class as follows . And in that class i am trying to crate xml document by ''xml/libxml'' lib. Even adding require ''rubygems'' also my problum has not solved. I think the libxml gem is not installed properly. How can i check whether the gem is installed properly or not. class FirstRubyProgram require ''xml/libxml'' require ''rubygems'' doc = XML::Document.new() doc.root = XML::Node.new(''root_node'') doc.root << XML::Node.new(''elem1'') puts doc end -- Posted via http://www.ruby-forum.com/.
Direct from the libxml-ruby rdocs: ------------------ The libxml gem provides Ruby language bindings for GNOME’s Libxml2 XML toolkit. To get started you may: require ''xml'' document = XML::Document.new However, when creating an application or library you plan to redistribute, it is best to not add the LibXML module to the global namespace, in which case you can either write your code like this: require ''libxml'' document = LibXML::XML::Document.new ------------------ You should probably take some time to get familiar with gem documentation. See: http://docs.rubygems.org/read/chapter/2#page10 On Nov 12, 6:22 am, Chinna Gogulapati <rails-mailing-l...@andreas- s.net> wrote:> Hi Sijo, > > What i mean is, i created a simple ruby class as follows . And in that > class i am trying to crate xml document by ''xml/libxml'' lib. Even adding > require ''rubygems'' also my problum has not solved. I think the libxml > gem is not installed properly. How can i check whether the gem is > installed properly or not. > > class FirstRubyProgram > require ''xml/libxml'' > require ''rubygems'' > > doc = XML::Document.new() > doc.root = XML::Node.new(''root_node'') > doc.root << XML::Node.new(''elem1'') > puts doc > end > > -- > Posted viahttp://www.ruby-forum.com/.
Hi> . How can i check whether the gem is installed properly or not. >You can check with gem list> class FirstRubyProgram > require ''xml/libxml'' > require ''rubygems'' > > doc = XML::Document.new() > doc.root = XML::Node.new(''root_node'') > doc.root << XML::Node.new(''elem1'') > puts doc > endThe above should be class FirstRubyProgram require ''rubygems'' require ''xml/libxml'' doc = XML::Document.new() doc.root = XML::Node.new(''root_node'') doc.root << XML::Node.new(''elem1'') puts doc end Sijo -- Posted via http://www.ruby-forum.com/.
Hi Sijo/Rick, Thanq very much for your response and finally i got the result with the following stuff.> require ''libxml'' > document = LibXML::XML::Document.newThanq Chinna -- Posted via http://www.ruby-forum.com/.