HI,
Can any body tell me how to read a XML file using Java to obtain its contents.
Printable View
HI,
Can any body tell me how to read a XML file using Java to obtain its contents.
"zahid" <zsultan@hotmail.com> wrote:
>
>HI,
>
>Can any body tell me how to read a XML file using Java to obtain its contents.
Please view this site www.ibooks.com/xml and you'll find
your answer as well as many other things too, it is
slowly downloaded but read it don't leave it.
Ali
(XML & JAVA Programmer)
<MICROSOFT>
<CALIFORNIA>
"zahid" <zsultan@hotmail.com> wrote:
>
>HI,
>
>Can any body tell me how to read a XML file using Java to obtain its contents.
>
>
You need an XML parser. These are divided into 2 categories.
DOM (Document Object Model) parsers read the entire document into
memory and return a handle to the root of the document. You use
class methods to navigate the document and get at the data.
SAX (Simple API for XML) 'streams' through the document and invokes
callbacks (that you register ahead of time) based on what the parser
is seeing at the moment. (Start tag, end tag, data, etc.).
DOM parsers are better for small-to-medium sized documents, SAX
parsers are better for large documents.
Some parsers from both categories will validate the document, that
is compare the document to its DTD. This may or may not be important
to you.
Check out Sun's and IBM's web sites. I believe there are free
XML parsers available there. Sorry I can't quote the exact URLs.
Hope this helps,
Dom