Reputation: 139
I want to read a large xml file which includes n number of elements 'elem1'. n can be up to 10.000 or more. I want to read each eleme1 as a DOM document, process it and read next elem1 etc. All articles I found so far suggest using StaxEventItemReader. But I don't want to map the peeked 'elem1' to an object but a DOM document. The reason is, that the business logic which I want to integrate in proccessor allready exists. The logic handles with a DOM Document(reading Nodes etc..). However StaxEventItemReader expects a class type to map the read data to. Is there any way to read data just as a dom document? I was thinking of a multiline records reader and defining open/close tags as tockenizers. But I don't know if this is possible and whether it is the right way?
<root>
<elem1>
<a>...</a>
<b>...</b>
</elem1>
<elem1>
<a>...</a>
<b>...</b>
<c>...</c>
</elem1>
</root>
Upvotes: 0
Views: 287
Reputation: 31590
Since you are able to parse a string element into a DOM object, you can proceed as follows:
StaxEventItemReader<String>
to read string elementsUpvotes: 1