Added fix for the IsValid method not handling invalid XML