I got following (in reality huge) XML to process:
<root>
<item attr="hello world">
<subitem></subitem>
<subitem></subitem>
<subitem></subitem>
<subitem></subitem>
</item>
<item attr="hello world">
<subitem></subitem>
<subitem></subitem>
<subitem></subitem>
<subitem></subitem>
</item>
.
.
.
</root>
With StaxMate this is pretty easy. But how on earth do I tell StaxMate to "record" e.g. the plain XML for each item (see XML above). So that after processing the an item I have done my processing on it + I have the String
<item attr="hello world">
<subitem></subitem>
<subitem></subitem>
<subitem></subitem>
<subitem></subitem>
</item>
somewhere.
Thank you very very much, Fabian
You need to write entries; XMLStreamWriter2 has nice method,
XMLStreamWriter2.copyEventFromReader(...)
which can be used to make exact copy of the token.But why are you creating
String
s at all? Wouldn't it make sense to either directly write XML fragments, or process them? Strings are inefficient things to use with XML; take up memory, need to be encoded when written out, parsed when they contain XML. So about the only reason to do this is if they must be passed as Strings to another library.