473,385 Members | 1,930 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,385 software developers and data experts.

Best method to parse a very large XML Doc

Hi all,

I have an xml document that can contain 248 nodes with
each node containing different fields. There is the
possibility that there will be more nodes. Each node can
have up to 30 elements.

What do you suggest is the best way to parse through this
document? Should I create a class and deserialize the
xml into it? Should I create a giant parsing routine?
etc...

Thank everyone in advance for their answers!

Brian
Nov 15 '05 #1
2 3100
Brian,

Depending on what you are trying to do, your best bet might be to use a
class that derives from XmlReader. This will allow you to read the contents
in a streaming manner and will be much more efficient than loading a large
file like this into memory. However, it might not suit your needs. If you
need to access this information over and over again, then storing it in a
class (through XML serialization, like you mentioned) might be the better
route for you.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

"Brian" <no****@hotmail.com> wrote in message
news:02****************************@phx.gbl...
Hi all,

I have an xml document that can contain 248 nodes with
each node containing different fields. There is the
possibility that there will be more nodes. Each node can
have up to 30 elements.

What do you suggest is the best way to parse through this
document? Should I create a class and deserialize the
xml into it? Should I create a giant parsing routine?
etc...

Thank everyone in advance for their answers!

Brian

Nov 15 '05 #2
No offense, but your XML document doesn't sound all that large. If the XML
file is less than 1MB in size, just use an XmlDocument and pull your data
out as you need it using XPath. If you haven't worked with it before, XPath
is a pretty decent query language that returns multiple nodes from anywhere
in the document. This is just about the most powerful method of getting
things out of an XML document available, if the document isn't too big to
fit in memory neatly as an XmlDocument.

If the document is big - you'll have to decide what "big" means - you can
use XmlReader, but the programming will be a lot more difficult. XmlReader
is a one-pass reader. There is no backtracking, no hierarchy, no state
(other than the state managed by the code you write). You'll have to pull
out the information you need as you parse and store it in a convenient
format. If the document is 10MB or bigger, you'll probably have to do
things the hard way.

If you can possibly work with XmlDocument, do so. Your code will be much
simpler and easier to maintain.

"Brian" <no****@hotmail.com> wrote in message
news:02****************************@phx.gbl...
Hi all,

I have an xml document that can contain 248 nodes with
each node containing different fields. There is the
possibility that there will be more nodes. Each node can
have up to 30 elements.

What do you suggest is the best way to parse through this
document? Should I create a class and deserialize the
xml into it? Should I create a giant parsing routine?
etc...

Thank everyone in advance for their answers!

Brian

Nov 15 '05 #3

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

Similar topics

18
by: Moonlit | last post by:
Hi, I am searching for the best lex and yacc combination (or something similar) that can be used in combination with C++ and that can contain C++ code. I have the regular flex/bison port working...
2
by: Jim Williams | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** I'm working on a 3d engine system. I need to save/load data in the systems objects to/from XML files. When I say objects, I mean...
4
by: Chuck Ritzke | last post by:
I keep asking myself this question as I write class modules. What's the best/smartest/most efficient way to send a large object back and forth to a class module? For example, say I have a data...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
20
by: Joe | last post by:
Is any one charting packing considered to be the "best"? We've used ChartFX but wasn't too happy about the way data had to be populated along with some other issues which slip my mind right now and...
2
by: David T. Ashley | last post by:
Hi, In my PHP code, I typically break my functions into groups (usually based on the data type they operate on), and then include the files, i.e.: require_once("string_functions.inc");...
9
by: Steve Richter | last post by:
in a generic class, can I code the class so that I can call a static method of the generic class T? In the ConvertFrom method of the generic TypeConvert class I want to write, I have a call to...
4
by: trullock | last post by:
Hi, Can anyone suggest the best way to go about the following... I'm tracking clicks (mouse down x,y coordinates) on a web page by using some javascript to create an XHR which sends the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.