Re-worked the logic for handling isXML detection.