@Override public String serializeXMLEvents(List<XMLEvent> xmlEvents, boolean isHtml) { final XMLOutputFactory outputFactory; if (isHtml) { outputFactory = this.getHtmlOutputFactory(); } else { outputFactory = this.getXmlOutputFactory(); } final StringWriter writer = new StringWriter(); final XMLEventWriter xmlEventWriter; try { xmlEventWriter = new IndentingXMLEventWriter(outputFactory.createXMLEventWriter(writer)); } catch (XMLStreamException e) { throw new RuntimeException("Failed to create XMLEventWriter", e); } try { for (final XMLEvent bufferedEvent : xmlEvents) { xmlEventWriter.add(bufferedEvent); } xmlEventWriter.flush(); xmlEventWriter.close(); } catch (XMLStreamException e) { throw new RuntimeException("Failed to write XMLEvents to XMLEventWriter", e); } return writer.toString(); }
@Override public String serializeXMLEvents(List<XMLEvent> xmlEvents, boolean isHtml) { final XMLOutputFactory outputFactory; if (isHtml) { outputFactory = this.getHtmlOutputFactory(); } else { outputFactory = this.getXmlOutputFactory(); } final StringWriter writer = new StringWriter(); final XMLEventWriter xmlEventWriter; try { xmlEventWriter = new IndentingXMLEventWriter(outputFactory.createXMLEventWriter(writer)); } catch (XMLStreamException e) { throw new RuntimeException("Failed to create XMLEventWriter", e); } try { for (final XMLEvent bufferedEvent : xmlEvents) { xmlEventWriter.add(bufferedEvent); } xmlEventWriter.flush(); xmlEventWriter.close(); } catch (XMLStreamException e) { throw new RuntimeException("Failed to write XMLEvents to XMLEventWriter", e); } return writer.toString(); }