- Joined
- May 5, 2009
- Messages
- 1
- Reaction score
- 0
I have to implement SAX parsing on one xml. In SAX parsing, parser reads XML line by line. So it can look ahead. Now here is my XML structure(Note: Capital letters represent "ELEMENT" and small letters represent some value or attribute).
<xml>
<ELEMENT_A_COMPLEX>
<ELEMENT_B_STR>abc</ELEMENT_B_STR>
<ELEMENT_C_STR>abc</ELEMENT_C_STR>
<ELEMENT_D_COMPLEX>
<ELEMENT_B_STR>abc</ELEMENT_B_STR>
<ELEMENT_C_STR>abc</ELEMENT_C_STR>
<ELEMENT_A_COMPLEX>.......</ELEMENT_A_COMPLEX>
<ELEMENT_A_COMPLEX>.......</ELEMENT_A_COMPLEX>
<ELEMENT_D_COMPLEX>........</ELEMENT_D_COMPLEX>
</ELEMENT_D_COMPLEX>
</ELEMENT_A_COMPLEX>
</xml>
as you can see A and D are complex types. I have Classes for them. But they can contain object of type A,D again. So this will be nested tree depending upon XML. Now I want to create a general code which process this xml and create necessary tree with SAX implementation. Right now i'm maintaining an object which contains this,parent and child object and using Reflection API. Is there any better way to implement. Please suggest.
<xml>
<ELEMENT_A_COMPLEX>
<ELEMENT_B_STR>abc</ELEMENT_B_STR>
<ELEMENT_C_STR>abc</ELEMENT_C_STR>
<ELEMENT_D_COMPLEX>
<ELEMENT_B_STR>abc</ELEMENT_B_STR>
<ELEMENT_C_STR>abc</ELEMENT_C_STR>
<ELEMENT_A_COMPLEX>.......</ELEMENT_A_COMPLEX>
<ELEMENT_A_COMPLEX>.......</ELEMENT_A_COMPLEX>
<ELEMENT_D_COMPLEX>........</ELEMENT_D_COMPLEX>
</ELEMENT_D_COMPLEX>
</ELEMENT_A_COMPLEX>
</xml>
as you can see A and D are complex types. I have Classes for them. But they can contain object of type A,D again. So this will be nested tree depending upon XML. Now I want to create a general code which process this xml and create necessary tree with SAX implementation. Right now i'm maintaining an object which contains this,parent and child object and using Reflection API. Is there any better way to implement. Please suggest.