473,624 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Xml in DataSet

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(fileNam e);

Which one is better? I have seen few authors preferring the first way. Is
there anything special to it.
--
Bindesh Vijayan
MCP [ASP.NET]
Nov 12 '05 #1
2 1558


binvij wrote:

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) ;
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/frlrfSystemData DataSetMembersT opic.asp>
Perhaps you are asking about the method named ReadXml?
OR

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

Which one is better? I have seen few authors preferring the first way. Is
there anything special to it.


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/
Nov 12 '05 #2

Thanks for the correction. I meant ReadXml().

Yes perhaps your explanation is right.

thnx
"Martin Honnen" wrote:


binvij wrote:

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) ;


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/frlrfSystemData DataSetMembersT opic.asp>
Perhaps you are asking about the method named ReadXml?
OR

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

Which one is better? I have seen few authors preferring the first way. Is
there anything special to it.


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/

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2779
by: David D. McCrory | last post by:
I have the following that returns an array of a struct and I want to load it into a DataSet on the consumer side.....Can someone provide me with an example of how to use the DataSet.ReadXml() function with an array of a struct?? public State GetState2() { int cnt; DataSet ds = new DataSet(); try
0
1114
by: Earl Teigrob | last post by:
I would like to be able to validate an XML file before it is (or as it is being) read into a DataSet. I have a class that dynamically creates a DataSet with typed columns based on another "record definition" class. Then I use this DataSet to write and read data to and from an XML file My issue is that I as I make revisions to my application and change the type of data a certain (DataSet Column) node contains, It causes my DataSet to...
5
1326
by: WebBuilder451 | last post by:
is there ant place where i can learn the basics of reading an rss feed and enumerating through the values? just want to start at the bottom, no frills. thanks -- thanks (as always) some day i''m gona pay this forum back for all the help i''m getting kes
1
2176
by: hzgt9b | last post by:
(FYI, using VB .NET 2003) Can someone help me with this... I'm trying to read in an XML file... it appears to work in that the DataSet ReadXML method dose not fail and then I am able to access the table names that are in the XML file, but I'm not able to access the rows. Here's the code that I've got - it assumes that the fileName passed in already exists: Public Sub GetInput(ByVal fileName As String) dsFileCopy = New...
4
12785
by: Amit Maheshwari | last post by:
I need to read text file having data either comma seperated or tab seperated or any custom seperator and convert into a DataSet in C# . I tried Microsoft Text Driver and Microsoft.Jet.OLEDB.4.0 to read text file but could not get the data in correct format. All columns are not coming in dataset and rows are messing up. Suggestions please ???
3
8025
by: Brad | last post by:
I'm having a problem reading data from an Excel file into a dataset. Can anybody give me an idea of what's happening? I've included the problematic source and the error message to the end of this message. TIA Brad Here's a snippet of my source code:
0
361
by: David | last post by:
Hi, using C# 1.1 I am writing a winform app that collects a dataset from a webservice. At the same time I collect the data, I write the dataset out to the local disk using DataSet.WriteXml, so that if the webservice is not available, then the app will continue to run from my saved dataset. If the web service is not available, then I load the dataset with the ReadXml method.
5
5223
by: Hetal | last post by:
Hi there.. I am a VB6 developer so kinda trying to figure how to work with VB.NET. I have a scenario where i have a DataSet bound to a combo box, and i would like to read a row from the DataSet based on the item selected in the Combo Box. For e.g. I have a dataset that has 1 table containing 3 fields say ID, Name, and Address.
2
1936
by: pkenderdine | last post by:
Can someone please advise the best approach for reading in many 5000+ xml files from disk into a data set. Here is the code so far. On my computer (may not be best spec) is takes about 3 minutes to read and load the dataset. It doesn't seem to be the reading of the files as so much as the loading of the data into the dataset. Any help would be appreciated. cenOcr = new DataSet(); // Create the XmlSchemaSet class. XmlSchemaSet sc = new...
1
4694
by: sachinkale123 | last post by:
Hi, I am reading excel file and reading values from that I am using provider As : "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + Filename + ";Extended Properties=\"Excel 8.0;Hdr=No;IMEX=1\""; Column Name 'Sol 1' and 'Sol 2' is missing even though it is reading the readings. Just not able to read column names. I am not sure about what is exact problem. so please help me in solving this. Thanx in advance.
0
8170
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8334
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6108
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.