Pulled out DOM parsing code into new class.