I just faced an issue while de-serializing a XML file to specific type or object class. Actually normal XML file without Namespace gets de-serialized easily but when you de-serialize XML with Namespace it gives following error

“There is an error in XML document”

Resolution is very simple actually you just need to include Namespace with XMLSerialization Class and exception will go away.

XmlSerializer serializer = new
XmlSerializer(typeof(Books), http://schemas.com/BooksSchema”);

Books books = (Books)serializer.Deserialize(new System.IO.FileStream(“XmlDeserializationSample.xml”,System.IO.FileMode.OpenOrCreate));

encoding=utf-8 ?>




<ns1:Author>Scott Hanselman</ns1:Author>