in reply to xml/html detection script
I'm not sure if what you're asking is what you want. A URL request is like so: http://www.perlmonks.org - that's it... I've requested a URL (and what's more, that's actually an HTTP request). What do I want returned? XML or HTML? I don't know.
Now if I say http://www.perlmonks.org/index.html then more than likely it's an HTTP request for HTML. So if you're truly looking to determine what the REQUEST is for, then just look at the extension. Otherwise, it's anyone's guess.
If you're looking for the response type, the other answers can lead you in that direction.