I'm inferring from a re-read of the thread that at times the NWS was returning a 404 error (not found) for particular codes. In that case, it will return HTML instead of XML - the error messages indicate that it was getting an HTML header: "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">".
Curly, is this the error case the new code handles correctly?
To see this yourself, try a bogus URL like:
http://alerts.weather.gov/cap/get.php
and then look at the source that is returned (vs the XML source on a good "get").