Search code examples
javaxmldomsaxstax

How do I parse this XML File in Java


I have the following file in xml and I need to Parse it in Java. The file has more than 200 rows, I just gave two rows as sample.

Please help with best method to parse large files ie DOM, SAX, StaX and a working example to prase this file would be greatly appreciated - Thanks

<?xml version="1.0"?>
<vdb>
    <database_data>
        <table_data name="Messages">
            <row rowid="1">
                <col name="firstname"> yong </col>
                <col name="lastname"> mook </col>
                <col name="nickname"> mkyong </col>
                <col name="salary"> 100000 </col>
             </row>
            <row rowid="2">
                <col name="firstname"> foo </col>
                <col name="lastname"> yah </col>
                <col name="nickname"> fyah </col>
                <col name="salary"> 200000 </col>
            </row>
        </table_data>
    </database_data>
</vdb>

Solution

  • Take look at Java API for XML Processing for starters