I am trying to provide information from friendfeed's API.
As you can see in the code, I use HttpRequest to get the information. This is normal.
After that I read XML perfectly with LINQ.
But now I am creating a "feed" class, and I want to create an object for each return value (i from finaltoclass).
How can i do this?
Can you help me?
Thanks.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO; using System.Xml; using System.Xml.Linq; namespace ConsoleApplication1 { class Program { class feed { } public class entry { string body; string id; string url; public entry(string a, string b, string c) { body = a; id = b; url = c; } } static void Main(string[] args) { string username = "semihmasat"; WebRequest ffreq = WebRequest.Create("http://friendfeed-api.com/v2/feed/" + username + "?format=xml"); WebResponse ffresp = ffreq.GetResponse(); Console.WriteLine(((HttpWebResponse)ffresp).StatusDescription); Stream stream = ffresp.GetResponseStream(); StreamReader reader = new StreamReader(stream); string respfinal = reader.ReadToEnd(); reader.Close(); XElement final = XElement.Load("http://friendfeed-api.com/v2/feed/" + username + "?format=xml"); var finaltoclass = from i in final.Elements("entry") select i; foreach (XElement i in finaltoclass) { string body= i.Element("body").Value; string id= i.Element("id").Value; string url= i.Element("url").Value; Console.WriteLine("{0},{1},{2}", body, id, url); } Console.ReadLine(); } } }
source share