Re: Java with xml
From: Fahd Shariff (fahdshariff_at_yahoo.com)
Date: 03/07/05
- Next message: Thomas Schodt: "Re: how to get threadName from threadID?"
- Previous message: Jesper Nordenberg: "Re: Genercis advice"
- In reply to: glin_at_tollnz.co.nz: "Java with xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 7 Mar 2005 01:43:03 -0800
There are three main XML parsing techniques:
- Document Object Model (DOM),
- Simple API for XML (SAX),
- Streaming API for XML (StAX) - NEW
DOM:
Tree-based parsing technique that builds up an entire parse tree in
memory.
- DOM is straightforward.
- You can access the XML document randomly because the entire tree is
built in memory.
- The DOM APIs allow modification of the nodes, such as appending a
child or updating or deleting a node.
Loading the whole document and building the entire tree structure in
memory can be expensive, especially when the document is large. It can
also consume a lot of memory.
DOM parsing is appropriate when the application needs to have random
access to the XML document. Because DOM enables you to update the
document, it is also convenient for applications, such as XML editors,
that need to modify data.
SAX:
Rather than building a tree representation of an entire document as DOM
does, a SAX parser fires off a series of events as it reads through the
document. These events are pushed to event handlers, which provide
access to the contents of the document.
The SAX model has the major advantage of low memory consumption,
because the entire document does not need to be loaded into memory at
one time, which enables a SAX parser to parse a document larger than
the system memory. The disadvantages are:
- need to implement the event handlers to handle all incoming events
- it does not have built-in document navigation support such as that
provided by XPath. This, coupled with its one-pass parsing, means there
is no random access support.
- poor choice for manipulating or modifying a document
-- Fahd Shariff http://www.fahdshariff.cjb.net "Let the code do the talking... "
- Next message: Thomas Schodt: "Re: how to get threadName from threadID?"
- Previous message: Jesper Nordenberg: "Re: Genercis advice"
- In reply to: glin_at_tollnz.co.nz: "Java with xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|