Found issue with newer versions of .NET and malformed XML

Added function MalformedXML and logic to enable or disable it as needed.