Brought the logic for handling isXMLDoc over from Sizzle.