public void parseEvents ( MarcXchangeEventConsumer consumer ) throws XMLStreamException { Objects . requireNonNull ( consumer ) ; if ( builder . getMarcListeners ( ) != null ) { for ( Map . Entry < String , MarcListener > entry : builder . getMarcListeners ( ) . entrySet ( ) ) { consumer . setMarcListener ( entry . getKey ( ) , entry . getValue ( ) ) ; } } XMLInputFactory inputFactory = XMLInputFactory . newInstance ( ) ; XMLEventReader xmlEventReader = inputFactory . createXMLEventReader ( builder . getInputStream ( ) ) ; while ( xmlEventReader . hasNext ( ) ) { consumer . add ( xmlEventReader . nextEvent ( ) ) ; } xmlEventReader . close ( ) ; }
Run XML stream parser over an XML input stream with an XML event consumer .