I spend much of my day inside various text editors hacking away at the various projects that work demands of me. A good editor can make the difference between getting the job done quickly and languishing in a copy-paste-edit-repeat nightmare.
I’d like to offer you a list of editors that I use with a small comment about each one. I’ll follow up with some brief product reviews pointing out what I like and don’t like about each one.
TextWrangler – The grandson of BBEdit. Lags behind in features but makes up for it in price: free
TextMate – an editor with amazingly powerful tricks up it’s sleeve.
Coda – all in one web-site oriented editor. My PHP-coding coworkers love this program.
Espresso – a new editor. Part of the MacHeist bundle. I have not tried it yet, but it looks promising. From the same folks who do CSSEdit. Web-site oriented like Coda.
Affrus – a Perl-oriented editor that includes a GUI interface to Perl’s deubgger. If you do any work in perl, Affrus is a must. It’s saved me countless hours by letting me debug down into the Perl libraries to find errors that don’t get reported up correctly.
CSSEdit – a CSS editor. Listen, someday you will ahve to break down and create/edit a CSS file. CSSEdit makes that experience much less painful.
This is a nice piece of software. If you do any LDAP work it’s worth the time to download and try out. I don’t have to boot windows to use LDAPBrowser anymore!
Here’s a question posted to a mailing list that I follow:
I just want to go through the xml and return the names of all the elements as well as the names of their attributes. It seems that most of the time, people know the name of the tag they’re looking for, and they want to get the inner html or the value of one of its attributes.
Is there a method in Hpricot or REXML that enables you to just get a list of all the tag names and attributes?
Here’s my solution:
#!/usr/local/bin/ruby
require 'rubygems'
require 'hpricot'
doc = Hpricot(open("x.xml"))
elements = Array.new
attributes = Array.new
doc.search("//*").each do |e|
if e.class == Hpricot::Elem
elements << e.name
e.attributes.each do |a|
attributes << a[0]
end
end
end
puts "Elements:"
puts elements.join("\n")
puts
puts "Attributes:"
puts attributes.join("\n")
It's ugly, but it gives you an array of elements and attributes. You could run sort and unique on the arrays if you wanted to get a stripped down list.