How to read a big XML file in JAVA and Spilt it into small XML files Based on Tag using Stax or SAX parser?

Hi ,
I am new to JAVA programming and Parsers, now I in need of JAVA program to read a big XML file that containing … tags. Sample input as follows.

Input.xml

<row>
<Name>Filename1</Name>
</row>
<row>
<Name>Filename2</Name>
</row>
<row>
<Name>Filename3</Name>
</row>
<row>
<Name>Filename4</Name>
</row>
<row>
<Name>Filename5</Name>
</row>
<row>
<Name>Filename6</Name>
</row>
 .
 .
I need output as first <row> </row> as a single .xml file with filename as filename1.xml and second <row>..</row> as filename2.xml and so.

Can anyone tell the steps how to do it in simple way with Java, it will be very useful if you give any sample codes to process xml file using SAX/STAx parser ?


Thanks,
Sowmiya