How to convert XML Elements to of type Person ?
Elements :
XElement persons = XElement.Parse(
@"<persons>
<person>
<id>10001</id>
<name> Daniel </name>
</person>
<person>
<id>10002</id>
<name>Marshal</name>
</person>
<person>
<id>10003</id>
<name>Leo</name>
</person>
</persons>"
);
Person Type:
class Person
{
int personID;
string name;
public int PersonID
{
get {return personID;}
set {personID = value;}
}
public string Name
{
get {return name;}
set {name = value;}
}
}
I tried (incomplete & not sure whether valid approach )
Person[] Prns = from perns in persons.Nodes select new {perns};