posted 14 years ago
Hi,
How can I use a SAX Parser to split a huge XML file into multiple parts (I also will need to keep the hierarchy intact):
e.g.If the input xml is:
<institution>
<institution-name>Institute-123</institution-name>
<institution-address>Institute-address</institution-address>
<departments>
<department id="101">
<employee>
<name>Emp1-101</name>
</employee>
<employee>
<name>Emp2-101</name>
</employee>
</department>
<department id="102">
<employee>
<name>Emp1-102</name>
</employee>
<employee>
<name>Emp2-102</name>
</employee>
</department>
</departments>
</institution>
The Split XMLs must list the employee names with the department & institution details(with hierarchy intact).Thus, there will be 4 xmls in this case for employees
(Emp1-101.xml)
<data>
<institution-name>Institute-123</institution-name>
<institution-address>Institute-address</institution-address>
<department id="101">
<employee>
<name>Emp1-101</name>
</employee>
</department>
</data>
Similarly we need to have XMLs for Emp2-101, Emp1-102, Emp2-102
Please note that I cannot use DOM as the input XML is very huge.
Thanks,
Amit