473,322 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

XMLDomDoc vs XMLTextReader

I am trying to import some data into my objects and I have been using
XMLDoc.LoadXML(file), but someone told me that this is very memory intensive
that if I am reading a text file that I would be better off using
XMLTextReader. Has anyone had the same experience?
Nov 15 '05 #1
3 3454
That is true. The XmlDocument must load the entire XML structure in memory
and construct a tree. My unofficial guess is that the memory footprint is
probably exponential when given larger documents.

The XmlTextReader only processes what it has to and does not maintain a tree
structure. The XmlDocument allows you to go anywhere and to anything, the
XmlTextReader is forward-only and cannot be modified.

If you are only reading the document, and you know the structure, then an
XmlTextReader would be more efficient.

It is really a judgement call as to what you use.

"MFRASER" <mf*****@henwoodenergy.com> wrote in message
news:uV**************@TK2MSFTNGP09.phx.gbl...
I am trying to import some data into my objects and I have been using
XMLDoc.LoadXML(file), but someone told me that this is very memory intensive that if I am reading a text file that I would be better off using
XMLTextReader. Has anyone had the same experience?

Nov 15 '05 #2


Can I still use xpath agaisnt the xmltextreader?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3
Michael,

You cannot perform XPath queries against an XMLTextReader because
the object doesn't keep a tree in memory which represents the data.
XMLTextReader is sort of like a "firehose" cursor: it has a current
position, and while you're reading in the document, you can find out
the type of the current node (is it an element, a comment, an
attribute, etc.), but if you don't do something to store the data as
its read it all evaporates when the Read() method returns false at the
end of the file.

You can see an example of the XMLTextReader in action here:

http://www.xmlforasp.net/codebank/ut...er.aspx&font=3

Good luck,
Les Matheson
Integral Concepts, Inc.
http://www.ivsds.com
Fraser Michael <mf*****@henwoodenergy.com> wrote in message news:<ev**************@TK2MSFTNGP12.phx.gbl>...
Can I still use xpath agaisnt the xmltextreader?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #4

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

Similar topics

4
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
5
by: Geoff Bennett | last post by:
While parsing an XML document, my TextReader instance skips nodes. For example, in this fragment: <Person Sex="Male" FirstHomeBuyer="No" YearsInCurrentProfession="14"> <RelatedEntityRef...
2
by: Yuriy | last post by:
Hi, any ideas how to read XML fragment from TextReader? XmlTextReader constructor accepts only Stream or string as source Do I miss something? thanks Yuriy
1
by: RJN | last post by:
Hi I'm using XMLTextReader to parse the contents of XML. I have issues when the xml content itself has some special characters like & ,> etc. <CompanyName>Johnson & Jhonson</CompanyName>...
1
by: SHC | last post by:
Hi all, I did the "Build" on the attached code in my VC++ .NET 2003 - Windows XP Pro PC. On the c:\ screen, I got the following: Microsoft Development Environment An unhandled exception of type...
3
by: Kjeld | last post by:
My scenario: I'm using an XmlTextReader to Deserialize serveral classes from a single xml document. Every class i pass the source stream, containing the xml. Each class subsequently creates an...
2
by: Q | last post by:
I am feeding XmlTextReader a URL that returns the XML that then gets parsed. The URL forms a query that affects how much data is returned in XML but not the format of the data. The problem is...
2
by: XML reading with XMLTextReader | last post by:
im trying to read an xml file which is in the wwwroot folder.im using IIS on XP Prof. my code is...
4
by: CodeRazor | last post by:
I am trying to use an XmlTextReader to retrieve data. I need to use an XmlTextReader because it is faster than using an XmlDocument. I have found an inelegant way of retrieving each item's title...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.