I'm not sure that this is an "if all else fails" condition. From what I can see in the calling code (XML::Twig::parse -> XML::Parser::parse -> XML::Expat::parse) the other conditions are there to handle more specialized cases. The first condition handles the case where a filehandle has been passed in as the argument, the second handles a Tied Handle, and the third is there to handle a simple scalar which contains the string to be parsed.
If you read what I wrote closely you will see that this code works fine from the command line. It is in the browser that this error occurs.