I'am getting an error while deserializing xml. Error:There is an error in XML document (2, 2). inner Exception: Profile xmlns='' was not expected. here is my profile class, xml and read function:
public class Profile
{
private string _profilename;
private string _iprotocol;
private string _macaddress;
private string _prostatus;
public string ProfileName
{
get { return _profilename; }
set { _profilename = value; }
}
public string IProtocol
{
get { return _iprotocol; }
set { _iprotocol = value; }
}
public string MacAddress
{
get { return _macaddress; }
set { _macaddress = value; }
}
public string ProStatus
{
get { return _prostatus; }
set { _prostatus = value; }
}
}
my xml:
<?xml version="1.0"?>
<Profile>
<ProfileName>Test</ProfileName>
<IProtocol>192.168.1.1</IProtocol>
<MacAddress>60-e3-27-37-cf-60</MacAddress>
<ProStatus>Happy</ProStatus>
</Profile><?xml version="1.0"?>
<Profile>
<ProfileName>Test</ProfileName>
<IProtocol>192.168.1.1</IProtocol>
<MacAddress>60-e3-27-37-cf-60</MacAddress>
<ProStatus>Happy</ProStatus>
</Profile>
read function
private void XmlReader()
{
Profile[] Pro;
XmlSerializer Reader = new XmlSerializer(typeof(Profile[]));
TextReader txtReader = new
StreamReader(@"F://SerializationOverview.xml");
Pro = (Profile[])Reader.Deserialize(txtReader);
}