xml parsing with using java

Posted on 2004-12-01
Last Modified: 2013-11-23
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?


Question by:vbguy
    LVL 8

    Accepted Solution


    Expert Comment

    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);
    LVL 2

    Expert Comment

    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

    LVL 3

    Expert Comment

    Look at


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    sameEnds challenge 25 56
    java JDK Download 7 49
    JKS to store upstart data 2 51
    powerN  challenge 3 36
    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    The viewer will learn how to implement Singleton Design Pattern in Java.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now