My project is Asp.net Core
I want to convert XML data to C# class,XML data has a node PersonelInfo
I try to read XML but It's code not working.
How can I solve this code? What is my problem?
var xmlGetDetailsUser = new XmlDocument();
xmlGetDetailsUser.LoadXml(await responseMessageGetDetailsUser.Content.ReadAsStringAsync());
using (StringReader reader = new StringReader(xmlGetDetailsUser.InnerXml))
{
try
{
PersonelInfo data = (PersonelInfo)(serializer.Deserialize(reader));
}
catch (System.Exception e)
{ }
}
class
public class PersonelInfo
{
public string PersonelCode { get; set; }
public string Email { get; set; }
}
xmlGetDetailsUser.InnerXml
has this value :
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<ArrayOfPersonelInfo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"sample url .....\">
<PersonelInfo>
<PersonelCode>99999</PersonelCode>
<Email>test@test.com</Email>
</PersonelInfo>
</ArrayOfPersonelInfo>
when run my program show this exception in try catch
There is an error in XML