I'm parsing large XML document using pull parser (org.xmlpull.v1.XmlPullParser
). When I reach specific node I want to grab it and all its children as chunk of text (or just children is OK too) and save as String. What would be efficient way of achieving this? Anything better than (in essence) buffer.append('<').append(xpp.getName()).append('>')
?
Here's an example
<root id="root">
<node>
<grab-all-inside>
<!-- bunch of nodes, attributes etc. that needs to be saved as text -->
</grab-all-inside>
</node>
<node>
<grab-all-inside>
<!-- bunch of nodes, attributes etc. that needs to be saved as text -->
</grab-all-inside>
</node>
<node>
<grab-all-inside>
<!-- bunch of nodes, attributes etc. that needs to be saved as text -->
</grab-all-inside>
</node>
</root>
P.S. If you think I'm better off using some other parser or technique I'm open for suggestions. Just as a side note - these text chunks will be serialized to db with premise that at some point these will be extracted and parsed