Convert main parser to use DOM