Link to home
Start Free TrialLog in
Avatar of vbguy
vbguy

asked on

xml parsing with using java

Hi ,

I have to parse an xml file to get the various files.


This will be a stand alone java program that parses an xml file, reads the values and
create a flat file based on the data. I will be parsing about 2000 32kb xml files at one time.



Can someone tell me which is the best parser out there and give me a sample program the reads an xml file?

Thanks,
Arthur

ASKER CERTIFIED SOLUTION
Avatar of kiranhk
kiranhk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mattjustmull
mattjustmull

You could also try the javax.xml.parsers package.

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputStream in = new FileInputStream(filename);

Document doc = db.parse(in);
in.close();
as kiran hk said

SAX is the right parser for your scenario.

i suggest you one of the best java parsers accepted by the world. The source it self has many examples. you can download it from

http://xml.apache.org/xerces-j/

somasekhar
Look at
 - xml.apache.org/xmlbeans/
 - xstream.codehaus.org/