XML and dataset

  • Thread starter Thread starter venky
  • Start date Start date
V

venky

I am new to dotnet and xml. I have a questions. I have an xml with
different nodes and attributes.

I want to parse this xml, get the values and update my controls on my
web page.

whats the easiest and best approach. Any sample code will help or
detail description of what classes to create and how to use it


venky
 
venky said:
I want to parse this xml, get the values and update my controls on my
web page.

Returning a dataset and using data bindings is the easiest.
 
here is some sample code for you

DataSet ds= new DataSet();

string xmlPath = PHYSICAL_PATH_TO_XML;
StreamReader sr = new StreamReader(xmlPath);
ds.ReadXml(sr);
sr.Close();
//Return the table if you want
return ds.Tables[0];

The rest will be like a normal datatable operations
 
=?Utf-8?B?QW1hZGVsbGU=?= said:
here is some sample code for you

DataSet ds= new DataSet();

string xmlPath = PHYSICAL_PATH_TO_XML;
StreamReader sr = new StreamReader(xmlPath);
ds.ReadXml(sr);
sr.Close();
//Return the table if you want
return ds.Tables[0];

return ds - .NET 1.1 does not support returning single tables AFAIK.
 
kindda of a delayed response, but what chad is saying is not true,
in .NET 1.1 you can still return tables.
We use it all over the place in our code.

Thanks,

Amadelle

Chad Z. Hower aka Kudzu said:
=?Utf-8?B?QW1hZGVsbGU=?= said:
here is some sample code for you

DataSet ds= new DataSet();

string xmlPath = PHYSICAL_PATH_TO_XML;
StreamReader sr = new StreamReader(xmlPath);
ds.ReadXml(sr);
sr.Close();
//Return the table if you want
return ds.Tables[0];

return ds - .NET 1.1 does not support returning single tables AFAIK.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Blogs: http://www.hower.org/kudzu/blogs
 
=?Utf-8?B?QW1hZGVsbGU=?= said:
kindda of a delayed response, but what chad is saying is not true,
in .NET 1.1 you can still return tables.
We use it all over the place in our code.

How?

[WebMethod]
public DataTable GetCustomer() {
return Dataset.Customer;
}

Ive never tried it - but I've seen many many places that explicitly state this does not work and that this
is one of the additions in 2.0.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Stuff: http://www.KudzuWorld.com
Blogs: http://www.KudzuWorld.com/blogs
 
Back
Top