Better way for HTML parser?

I know my html parser is a hacky mess so does anyone have any advice on how to write a parser more efficiently. Here is the code: http://codejaw.com/8xkvhh
Yes. Don't. Use libxml2.
I said write, I want to learn from this
Topic archived. No new replies allowed.