in reply to xml/html detection script

I assume that by "URL request" you actually mean a HTTP request. But they are never XML or HTML, they are just plain text.

So I suspect that you're actually talking about the content type of the HTTP response, rather than the request. In that case you can just look at the content type header. If it's "text/html" then the body is HTML, if it's "text/xml" then the body is XML.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: xml/html detection script
by dorward (Curate) on Aug 17, 2005 at 15:10 UTC

    You'd also have to account for other XML Content-types, such as application/xml, application/xhtml+xml, application/rdf+xml, and so on.

    Something like this might work:

    if ($content_type =~ m!(application|text)/(.*\+)?xml!) { # Treat as XML }