Convert String XML to Datatable in C#


USing Facebook xml string api example

//Creating web client object

WebClient web = new WebClient();

//getting xml string example 
//your url name

string url = string.Format("https://api.facebook.com/method/fql.query?query=SELECT url, share_count, like_count, comment_count, total_count, click_count FROM link_stat where url=http://yoururlname.com");

//getting responce

string response = web.DownloadString(url);
DataSet ds = new DataSet();

//writting to dataset

using (StringReader stringReader = new StringReader(response))
{
ds=new DataSet();
ds.ReadXml(stringReader);
}
DataTable dt = ds.Tables[0];

Comments

Popular Posts