public static String encode ( List < XMLEvent > theEvents ) { try { StringWriter w = new StringWriter ( ) ; XMLEventWriter ew = XmlUtil . createXmlFragmentWriter ( w ) ; for ( XMLEvent next : theEvents ) { if ( next . isCharacters ( ) ) { ew . add ( next ) ; } else { ew . add ( next ) ; } } ew . close ( ) ; return w . toString ( ) ; } catch ( XMLStreamException e ) { throw new DataFormatException ( "Problem with the contained XML events" , e ) ; } catch ( FactoryConfigurationError e ) { throw new ConfigurationException ( e ) ; } }
Encode a set of StAX events into a String