Showing posts with label Ajax. Show all posts
Showing posts with label Ajax. Show all posts

Tuesday, 12 March 2013

Convert String XML to Datatable in C#

Here I will explain how to convert xml string to dataset or xml string to datatable in Asp.Net  using C# And Vb.Net

C#

WebClient web = new WebClient();
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://collageprogramming.blogspot.in");
string response = web.DownloadString(url);
DataSet ds = new DataSet();
using (StringReader stringReader = new StringReader(response))
{
ds=new DataSet();
ds.ReadXml(stringReader);
}
DataTable dt = ds.Tables[0];
Vb.Net
Dim web As New WebClient()
Dim url As String = 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://collageprogramming.blogspot.in/")
Dim response As String = web.DownloadString(url)
Dim ds As New DataSet()
Using stringReader As New StringReader(response)
ds = New DataSet()
ds.ReadXml(stringReader)
End Using
Dim dt As DataTable = ds.Tables(0)