Parsing multiple XML fragments with STaX
I was hoping the following would be parseable in StAX, <something a="b"/> <something a="b"/> But it chokes when you reach the second element. As there is no common root element. (I'm not too sure why a pull parser cares about this particular issue... anyway...) I can fake a root element, e.g. Guava: InputSupplier<Reader> join = CharStreams.join( newReaderSupplier("<root>"), newReaderSupplier(new File("...")), newReaderSupplier("</root>")); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader xsr = xif.createXMLStreamReader(join.getInput()); xsr.nextTag(); // Skip the fake root