linq xml string get item attributes
string str="<Users> <User UserCode=\"0\" UserName=\"1\" UserType=\"2\" OrgCode=\"3\" OrgName=\"4\" CorpCode=\"5\" CorpName=\"6\" DeptCode=\"7\" DeptName=\"8\" Email=\"9\" Sex=\"10\" /> <User UserCode=\"ewe\" UserName=\"1111\" UserType=\"2\" OrgCode=\"3\" OrgName=\"4\" CorpCode=\"5\" CorpName=\"6\" DeptCode=\"7\" DeptName=\"8\" Email=\"9\" Sex=\"10\" /></Users>";
XDocument doc = XDocument.Parse(str);
var nodes = from n in doc.Descendants("User")
select new { username = n.Attribute("UserName").Value, usercode = n.Attribute("UserCode").Value };
var nd = nodes.ToList();
foreach (var item in nodes)
{
Console.WriteLine(item.username + " -- " + item.usercode);
}