473,804 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3118
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)paldin o=at=exisconsul ting<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
10758
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 but then I, of course, can't use C++ constructs in the actions. I have tried spirit although I could make a simple command line parser (after too many hours), creating a parser tree with it was not possible in an easy way (the compiler choked...
2
4415
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 C++ objects. (These generally correspond to scene objects, but that consideration isn't important as far as loading/saving goes.) I think I have a reasonable grasp of XML, it's method of data representation, and parsing XML files.
4
2167
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 access module that creates a large disconnected dataset from a database. I want to pass that dataset back to the calling program. And then perhaps I want to send that dataset to another class module. At first it seems that the "object oriented"...
136
9468
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
0
4253
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 Applications and owner of Access Microsystems. Doug can be reached at doug@accessmicrosystems.com. --------------------------------------------------------------------------------
20
10057
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 Dundas has bugs and doesn't do a good enough job displaying axis labels and is very slow to paint large numbers of series and data points. We're currently evaluating ProEssentials which we are happy with but it's not a native .NET package. ...
2
4393
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"); require_once("large_integer.inc"); etc. The included files never contain any code that gets executed directly (it is
9
5851
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 the static Parse method of the conversion class. if (InValue is string) return T.Parse((string)InValue); else return base.ConvertFrom(context, culture, InValue);
4
1534
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 coordinates to a recording service, such as: /Record.ashx?X=123&Y=456
0
9712
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
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...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10089
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
9171
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
7634
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
5530
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...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3001
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.