You should define specific serialization parameters for your User class first:
[XmlRoot("users")]
[System.Xml.Serialization.XmlType(TypeName="user")]
public class User
{
public string Name { get; set; }
}
And since you want to read the "users" node, you should first get that node and deserialize that node:
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(xmlstring);
XmlNode usersNode = xmlDocument.SelectSingleNode("A/B/users");
StringReader sr = new StringReader(usersNode.OuterXml);
using (var reader = XmlReader.Create(sr))
{
List<User> resultda = (List<User>)serializer.Deserialize(reader);
Console.WriteLine(resultda.Count);
}
NOTE: It is always helpful to do it backwards if you have any problems with deserialization, meaning, just populate the object and serialize it, try/fail and finally get to your expected xml format
List<User> users = new List<User>();
users.Add(new User { Name = "User 1" });
users.Add(new User { Name = "User 2" });
new XmlSerializer(typeof(List<User>), new XmlRootAttribute("users")).Serialize(Console.OpenStandardOutput(), users);