private static List <AssemblaUser> getdata(string url, bool auth, string user, string password) { HttpWebRequest hr = WebRequest.Create(url) as HttpWebRequest; if (auth) { hr.Credentials = new System.Net.NetworkCredential(user, password); hr.PreAuthenticate = true; } hr.Method = "GET"; hr.ContentType = "application/xml"; HttpWebResponse wr = (HttpWebResponse)hr.GetResponse(); StreamReader sr = new StreamReader(wr.GetResponseStream()); XmlDocument xd = new XmlDocument(); string result = sr.ReadToEnd(); xd.LoadXml(result); List <AssemblaUser> docs = new List <AssemblaUser>(); XmlNodeList xnl = xd.GetElementsByTagName("user"); foreach (XmlNode xn in xnl) { AssemblaUser doc = new AssemblaUser(); foreach (XmlNode dc in xn.ChildNodes) { string m = dc.InnerText; if (dc.Name == "id") { doc.Id = m; } else if (dc.Name == "email") { doc.Email = m; } else if (dc.Name == "organization") { doc.Organization = m; } else if (dc.Name == "login_name") { doc.Username = m; } else if (dc.Name == "website") { doc.Website = m; } } if (doc.isValid) { docs.Add(doc); } } return(docs); }
private static List<AssemblaUser> getdata(string url, bool auth, string user, string password) { HttpWebRequest hr = WebRequest.Create(url) as HttpWebRequest; if (auth) { hr.Credentials = new System.Net.NetworkCredential(user, password); hr.PreAuthenticate = true; } hr.Method = "GET"; hr.ContentType = "application/xml"; HttpWebResponse wr = (HttpWebResponse)hr.GetResponse(); StreamReader sr = new StreamReader(wr.GetResponseStream()); XmlDocument xd = new XmlDocument(); string result = sr.ReadToEnd(); xd.LoadXml(result); List<AssemblaUser> docs = new List<AssemblaUser>(); XmlNodeList xnl = xd.GetElementsByTagName("user"); foreach (XmlNode xn in xnl) { AssemblaUser doc = new AssemblaUser(); foreach (XmlNode dc in xn.ChildNodes) { string m = dc.InnerText; if (dc.Name == "id") doc.Id = m; else if (dc.Name == "email") doc.Email = m; else if (dc.Name == "organization") doc.Organization = m; else if (dc.Name == "login_name") doc.Username = m; else if (dc.Name == "website") doc.Website = m; } if (doc.isValid) docs.Add(doc); } return docs; }