Introduction:
Here
I will explain how to convert xml string to dataset or
xml string to datatable
in asp.net using C#, VB.NET.
Description:
In
previous posts I explained Convert datatable to xml in asp.net, asp.net, C#, SQL Server Interview Questions, jQuery validate file extension in file
upload control,
send forgot password as email in
asp.net
and many articles relating to asp.net,
C#, VB.NET code snippets. Now I will explain how
to convert xml string to dataset or
xml string to datatable
in asp.net using C#, VB.NET.
C#
Code
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://aspdotnet-suresh.com");
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
Code
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://aspdotnet-suresh.com")
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)
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
1 comments :
This worked. Thanks :)
Note: Only a member of this blog may post a comment.