My XML string for deserializ
> <?xml version="1.0" encoding="utf-16"?> <ReceiveAccountSetting
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <POP3>POP3</POP3>
> <Server>webmail.in</Server>
> <AccountId>vivek.s@gmail.com</AccountId> <Password>123</Password>
> <EnableSSL>true</EnableSSL> <DefaultPort>25</DefaultPort>
> </ReceiveAccountSetting>
when try to deserilize it gives ERROR "There is an error in XML document (0, 0)"
My Class
public class ReceiveAccountSetting
{
/// <summary>
/// Receiving Email
/// </summary>
//public int AccountType { get; set; }
public string POP3 { get; set; }
public string IMAP { get; set; }
public string Server { get; set; }
public string AccountId { get; set; }
public string Password { get; set; }
public bool EnableSSL { get; set; }
public int DefaultPort { get; set; }
}
Method for deserilization
public EmailAccount Deserialize(string xmlstring)
{
EmailAccount objEmail = new EmailAccount();
XmlSerializer serializer = new XmlSerializer(typeof(EmailAccount));
StringReader reader = new StringReader(xmlstring);
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(xmlstring)))
{
objEmail = (EmailAccount)serializer.Deserialize(stream);
}
objEmail = (EmailAccount)serializer.Deserialize(reader);
return objEmail;
}