Guys I think I'm somewhere near with the below but also way off the mark still, I'm trying to fetch an xml then display the results into a datagrid using the below Webrequest, it doesn't throw an error but then It doesn't display either, am I missing the xml read part or am I overlooking something simple?
HttpWebRequest request = WebRequest.Create(http://myurl/xml) as HttpWebRequest;
// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
// Load data into a dataset
DataSet dsWeather = new DataSet();
dsWeather.ReadXml(response.GetResponseStream());
// display dataset information
dataGridView1.DataSource = dsWeather;
}

Suthish NairRank #92 · 22.8K reputationPosted Aug 27, 2011, 7:54 AM EDT
Did the url returns required output?
Put a break point on dsWeather and check it returns data table with records.
Did your DataGridview have same structure as data table?
mike DelvottiRank #7,298 · 244 reputationPosted Aug 27, 2011, 8:16 AM EDT
It doesn't populate the datagrid with any info but I'm sure it's contacting the remote xml file.
Sam HobbsRank #107 · 20.5K reputationPosted Aug 27, 2011, 9:25 AM EDT
Second note that ReadXml returns a DataSet, not a table. You need to specify which table in the data set to use.
The sample that you copied probably shows that. It shows the data that was read, correct? Try using the sample as-is to see what tables are returned.
mike DelvottiRank #7,298 · 244 reputationPosted Aug 27, 2011, 12:18 PM EDT
VulpesRank #55 · 29.2K reputationPosted Aug 27, 2011, 1:26 PM EDT
mike DelvottiRank #7,298 · 244 reputationPosted Aug 27, 2011, 1:49 PM EDT
the xml i'm contacting sits on a web server, i send the url with my credentials then bring back the xml, i'm fairly sure it gets to the xml it just won't fetch it back and read it into my datagridview?
VulpesRank #55 · 29.2K reputationPosted Aug 27, 2011, 2:22 PM EDT
As Sam intimated earlier, I'd try binding to the first DataTable rather than the DataSet as a whole:
dataGridView1.DataSource = dsWeather.Tables[0];
Sam HobbsRank #107 · 20.5K reputationPosted Aug 27, 2011, 2:39 PM EDT
I said "ReadXml returns a DataSet, not a table". For example see How To Read XML Data into a DataSet by Using Visual C# .NET; it shows use of the DataMember to specify a table name.
You probably copied sample code from one of the following two sites. If not then perhaps you are missing some useful code.
- Using Returned XML with C# - Yahoo! Developer Network
- Sommers tech journal: Using Returned XML with C#
That sample code is a console program that shows the tables in the data set created when a XML file is read. You can use that sample code to test the part of your code that gets the XML file.mike DelvottiRank #7,298 · 244 reputationPosted Aug 27, 2011, 3:58 PM EDT
Sam, yes you are right I did use the code from one of those sites as an example, but Vulpes that tip helped with the dataGridView1.DataSource = dsWeather.Tables[0];, as it then threw an error which pointed me in the right direction (I had my url wrong ;)
Just one other quick question vulpes, now it works binding to a datagrid could I dislpay the results to say textbox1, textbox2 and so on instead of a datagrid?
Thanks guys.
Sam HobbsRank #107 · 20.5K reputationPosted Aug 27, 2011, 4:51 PM EDT
Since you are asking for help from just Vulpes and ignoring my help, I will stop trying to help.
mike DelvottiRank #7,298 · 244 reputationPosted Aug 28, 2011, 1:03 AM EDT
Sam, it's not like that – I'm not ignoring your help I'm grateful of everybody's reply. I appreciate your help and I'm sorry if I've offended you.
VulpesRank #55 · 29.2K reputationPosted Aug 28, 2011, 1:10 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Aug 28, 2011, 6:19 AM EDT