From: Mark Hubbart Date: 2004-04-26T03:58:30+09:00 Subject: Re: rexml: how to get element type? On Apr 24, 2004, at 11:29 AM, Sean Russell wrote: >> Btw could it be somehow possible to have a smaller string >> repretsentation for rexml objects ? they screw up IRB work ;) > > Can you give me an example of what you'd like to see? If I can jump in here... That last time I tried working with rexml, I opened a medium sized xml file in irb. I created a new REXML::Document IIRC, and it automatically inspected it, since it was the return value. I literally took about five minutes for the text to scroll past on my screen; When I called .inspect.size on the result, it was somewhere around 1.5 megs. I kept working with it for a bit, adding a ";0" at the end of each line so it wouldn't inspect the return value. for example, a stored settings file I wanted to work with: >> (plist = open("com.apple.internetconfig.plist"){|f|f.read}).size => 228291 >> doc = Document.new(plist); 0 => 0 >> doc.inspect.size => 1424751 something useful would be a small list of attributes, the number of children, etc... just as long as it's no more than several lines of text. :) I credit my irb experience with rexml as the reason I still don't know how to use it. > By the way, I find the following to be useful when looking for > methods; it is almost always more readable that #inspect :-) > > obj.methods.sort I agree :) Also, this can be useful if that shows way to much still: (obj.methods - Object.new.methods).sort I added that to my .irbrc file defined as Object#less_methods. cheers, --Mark