I have by example following XML:
string xml =
@"<plist version='1.0'>
<dict>
<key>DataType</key>
<string>Employee</string>
<key>8000</key>
<dict>
<key>Id</key>
<string>8000</string>
<key>Prename</key>
<string>Walter</string>
<key>Name</key>
<string>Walter Lohner Stans</string>
<key>Initials</key>
<string>MAL</string>
</dict>
<key>8001</key>
<dict>
<key>Id</key>
<string>8001</string>
<key>Prename</key>
<string>Motorrad</string>
<key>Name</key>
<string> Meierskappel</string>
<key>Initials</key>
<string>MAM</string>
</dict>
<key>8004</key>
<dict>
<key>Id</key>
<string>8004</string>
<key>Prename</key>
<string>Hanspeter</string>
<key>Name</key>
<string>Altenbürger AG Horgen</string>
<key>Initials</key>
<string>FH</string>
</dict>
</dict>
</plist>";
I would like to get these 3 Employees as a List...
The Class Employee is also defined:
//Class
public class Employee
{
//Properties
public string Id { get; set; }
public string Prename { get; set; }
public string Name { get; set; }
public string Initials { get; set; }
}
How does the parsing work now, if I by example want now to pass the xml to a method and want to have a List (of Type Employees) with these 3 Employees?
I started by doing something like that:
public List<Employee> GetEmployees(string xml)
{
using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
{
}
}
But Actually I don't know how to iterate over all these "dicts" which describe one Employee and generally how to deal with.. Help would be appreciated.