I have XML which I am de-serializing,This is my XML
<?xml version=\"1.0\" encoding=\"utf-16\"?>
<UserInfo xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<UserName>First_User</UserName>
<Age>25</Age>
</UserInfo>
I have this class
namespace MyProject{
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http:/MyProject.ServiceContracts/2006/11", IsNullable = false)]
[DataContract]
public class UserInfo
{
private string username;
private string age;
[DataMember]
public string UserName
{
get
{
return this.username;
}
set
{
this.username = value;
}
}
[DataMember]
public string Age
{
get
{
return this.age;
}
set
{
this.age = value;
}
}
}
}
and I am doing this
XmlSerializer xmlSerSale = new XmlSerializer(typeof(UserInfo));
StringReader stringReader = new StringReader(myXML);
info = (UserInfo)xmlSerSale.Deserialize(stringReader);
stringReader.Close();
Its giving me exception,
{"<UserInformation xmlns=''> was not expected."}
how can I fix this?Any alternate way to fix this? I have to use this in WebService