Connecting Tech Pros Worldwide Help | Site Map

Reading Xml in DataSet

binvij
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi Guys ! I want your views on this

An xml file can be loaded into a dataset in the following ways:

XmlTextReader reader = new XmlTextReader("inrss.xml");
DataSet ds = new DataSet();
ds.Load(reader);

OR

string fileName = "inrss.xml";
DataSet ds = new DataSet();
ds.Load(fileName);

Which one is better? I have seen few authors preferring the first way. Is
there anything special to it.
--
Bindesh Vijayan
MCP [ASP.NET]
Martin Honnen
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Reading Xml in DataSet




binvij wrote:

[color=blue]
> An xml file can be loaded into a dataset in the following ways:
>
> XmlTextReader reader = new XmlTextReader("inrss.xml");
> DataSet ds = new DataSet();
> ds.Load(reader);[/color]

I don't think there is a method named Load, the methods are documented here:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetMembersTopic.asp>
Perhaps you are asking about the method named ReadXml?
[color=blue]
> OR
>
> string fileName = "inrss.xml";
> DataSet ds = new DataSet();
> ds.Load(fileName);
>
> Which one is better? I have seen few authors preferring the first way. Is
> there anything special to it.[/color]

Not really, if you want to load from a local file then you can use the
method overload which takes a string with the file name. But if you
wanted to load from a URL for instance then you might need an overload
that allows that, using an XmlTextReader is one way to achieve that.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
binvij
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Reading Xml in DataSet



Thanks for the correction. I meant ReadXml().

Yes perhaps your explanation is right.

thnx
"Martin Honnen" wrote:
[color=blue]
>
>
> binvij wrote:
>
>[color=green]
> > An xml file can be loaded into a dataset in the following ways:
> >
> > XmlTextReader reader = new XmlTextReader("inrss.xml");
> > DataSet ds = new DataSet();
> > ds.Load(reader);[/color]
>
> I don't think there is a method named Load, the methods are documented here:
> <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetMembersTopic.asp>
> Perhaps you are asking about the method named ReadXml?
>[color=green]
> > OR
> >
> > string fileName = "inrss.xml";
> > DataSet ds = new DataSet();
> > ds.Load(fileName);
> >
> > Which one is better? I have seen few authors preferring the first way. Is
> > there anything special to it.[/color]
>
> Not really, if you want to load from a local file then you can use the
> method overload which takes a string with the file name. But if you
> wanted to load from a URL for instance then you might need an overload
> that allows that, using an XmlTextReader is one way to achieve that.
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
>[/color]
Closed Thread


Similar .NET Framework bytes