Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Convert String XML to Datatable in C# | String XML to Datatset

Jan 29, 2013
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.

If you want to convert xml string to dataset you need to write a code as shown below

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.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

Anonymous said...

This worked. Thanks :)

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.