473,721 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to speed up the ReadXML?

Hi,

In my C# Windows Form project, I'm testing comparing using the SqlClient
with the ReadXML method.
The ReadXML method will read 2 .xml files, one is 4K, the other one is 3Mb,
both are on my PC's local drive.
However, I found that it takes approximately 9 seconds for the ReadXML
method, while the SqlClient method is about 2 seconds.
Now I have 2 quesitons here:
1. Is it possible to speed up the ReadXML?
2. When will my PC's erase DataSet's ReadXML memory?

Thanks for help.
Jason
Apr 1 '06 #1
2 2110
Jason,

ReadXML must parse the entire XML document before it can represent it
in a relational-like format, which uses a lot resources for large
documents. The SqlClient method will always be faster. There are a
number of ways to improve performance with XML data, see
http://msdn.microsoft.com/library/de...netchapt09.asp,
but I'm not sure these recomendations will help ReadXML.

Once your DataSet goes out of scope or you call Dispose() it will be
marked for garbage collection and the memory will be reclaimed.

-Carl

Apr 1 '06 #2
It should be noted that SqlClient will not always be faster than reading
an XML document. It depends on the size of the data, the structure, etc,
etc. Also, you have to consider the other factors in play here, namely, is
it appropriate to store this information in the database as opposed to a
config file which is most likely stored locally?

On top of that, it should be noted that calling Dispose on the DataSet
will not mark it for garbage collection. The Dispose pattern on the DataSet
is inherited from the MarshalByValueC omponent class, and the DataSet does
nothing to override that behavior. The only thing that calling Dispose on
the DataSet does is fire the Disposed event.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Carl" <cz******@gmail .com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. .
Jason,

ReadXML must parse the entire XML document before it can represent it
in a relational-like format, which uses a lot resources for large
documents. The SqlClient method will always be faster. There are a
number of ways to improve performance with XML data, see
http://msdn.microsoft.com/library/de...netchapt09.asp,
but I'm not sure these recomendations will help ReadXML.

Once your DataSet goes out of scope or you call Dispose() it will be
marked for garbage collection and the memory will be reclaimed.

-Carl

Apr 1 '06 #3

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

Similar topics

11
408
by: DraguVaso | last post by:
Hi, I should use XML to synchronize the data from different (VB.NET) applications, and I was just wondering which Overloads of these functions ( ReadXmlSchema, ReadXml and WriteXml) goes the fastest? I don't think the ReadXMLSchema would give a lot of difference, but maybe the overlaods of ReadXml and WriteXml will. Especially with larges files/datatables... Should I use the IO.Stream? The XmlReader/XmlWriter?
1
4826
by: Jeffrey A. Voigt | last post by:
I'm having trouble loading some xml data into a dataset via the ReadXML call. I'm loading into the dataset an xml schema prior to the ReadXML call. I see that there IS in fact, 3 records that should be created in the dataset with the provided xml. However, after the ReadXML statement there are no rows in the DataSet.Tables ? IS there something I'm missing? I can assure you that the schema is correct, since it was originally created with...
1
5818
by: mr_dom_is | last post by:
Hi I have a little bit of trouble, probably missing the point now sure but: I have a dataset dim ds as new dataset("User") Which is populated with data from a database. When I use
8
5684
by: Nikhilesh Mehendale | last post by:
I have written a web service in C#, .NET 1.1 which reads a XML file into a dataset. This is just a plain XML file. First I use the Dataset.ReadXmlScheme function and pass the XML file to it. Then I convert data type of one of the column to integer and then I use the Dataset.ReadXml function and pass the same file to it. This works on my machine, but when I run it on a .NET 2.0 machine it thows an exception with message "Input string was...
1
2103
by: CB | last post by:
Using C# in .Net 2003, DataSet.ReadXml fails when a percentage (%) sign is in the filename followed by 2 hex characters. Seems that the % sign is likely encoding the following 2 hex characters. So c:\test%ab.xml fails for ReadXml since %ab is interpreted as 171 and c:\test171.xml does not exist. There is no problem with c:\test%mn.xml because "mn" is not a hex code. If I replace the % sign with %25 (25hex = 37dec = ascii code for %),...
5
2137
by: James Morton | last post by:
I have a Static DataSet in a class file that I am using globally between a few forms. The main form populates the dataset through a menu option which invokes ReadXML in the class file to populate the DataSet. The ReadXML is a rather lengthy operation with >5mb xml files (I am reading in the schema and ignoreschema on read). This has presented several problems 1) What kind of progress bar can I show during load since I can't increment...
3
2399
by: Raj Chudasama | last post by:
I am trying to read an xml file and have it view data in the datagrid. (For example take the xml file viewer in the visual studio, when u open an xml file it has that nice readable grid). I though that when i use the ReadXml funtion it will automatically read data and add the data to the datagrid. but i am wrong its not that simple. so i need help only with adding the data to the datagrid. this is what i have so far. I have created...
2
4818
by: C Glenn | last post by:
I'm attempting to use ReadXml. It's working in that I end up with some data in the DataSet. But I'm not able to deal with it effectively after that. The XML file is properly formatted in that it was created with WriteXML, so it contains the name of the table (I've inspected it to be sure). But after calling ReadXml the DataSet does not contain a table with the specified name. In fact, Tables does not contain a table corresponding to...
1
2383
by: ray well | last post by:
i saved the state of a data set and table via MyDs.WriteXmlSchema("MyDs.xsd") MyDs.WriteXml("MyDs.xml") i was able to read them back in and display the info in the database by MyDs.ReadXmlSchema("MyDs.xsd") MyDs.ReadXml("MyDs.xml")
0
8738
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,...
1
9150
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
9086
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8028
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...
0
5994
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
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
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
2599
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2146
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.