in reply to Parsing XML...by hand (ugh)

Maybe this will give you some ideas on how to proceed:

Perl XML-like parser.