HTML Parsing with Ruby and Nokogiri - Parsing HTML is a frequent and somewhat annoying task programmers are commissioned with occasionally. Activities such as screen-scraping have become rare since the advent of RSS, but still... There's always content out there that you have to get at that leaves you no choice but to parse it out yourself. One of the more elegant bits that I've seen for this purpose is Nokogiri which is a Ruby library that supports querying HTML content by both an XPath and CSS selector syntax. XPath First I'll demonstrate how to parse some content out of a page via the XPath syntax. This code uses the ruby documentation for the Bignum class as a parsing medium and essentially extracts the method names. require 'nokogiri' require 'open-uri' doc = Nokogiri::HTML(open('http://www.ruby-doc.org/core/classes/Bignum.html')) doc.xpath('//span[@class="method-name"]').each do | method_span |...
Templating with NDjango - It never ceases to amaze me how many great open source tools and libraries have been ported to .Net. NUnit... NHibernate... NAnt... All incredibly widely adopted. Today, however I'd like to focus one that a coworker brought to my attention which may actually get some use at the office, NDjango. During my recent Django work I've become quite attached to Django's template language. It took me a while to warm up to it but I'm hooked. When I heard that the templating had been ported to .Net I was naturally quite interested. Examples As you'd expect, there really isn't all that much to it. Consider the following code /* The data we'll pass into the template */ Dictionary<string, object> context = new Dictionary<string, object>(); context.Add("name", "Chris Umbel"); context.Add("profession", "Database Administrator"); /*...











