|
-
June 6th, 2008, 06:54 PM
#4
Re: how to read XML file in Java?
You can do it two main ways - either with DOM (Document Object Model), which loads the whole XML file as a Document, or with SAX (Simple API for XML), which reads the file and calls into your code with details of each element.
DOM is easier to use for small files, and gives you 'random access' to the elements, but takes a while and a lot of memory to load large files. Sax is a bit fiddly to use, but relatively lightweight and fast, and better suited sequential processing of large files.
See Parse Using SAX or DOM for (limited) examples.
The ability to simplify means to eliminate the unnecessary so that the necessary may speak...
H. Hofmann
Last edited by dlorde; June 6th, 2008 at 06:56 PM.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|