XMLInputFactory: createXMLEventReader(Reader reader)
import java.io.FileReader; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.events.XMLEvent; public class Main { public static void main(String args[]) throws Exception { XMLInputFactory xmlif = XMLInputFactory.newInstance(); XMLEventReader xmler = xmlif.createXMLEventReader(new FileReader("yourFile.xml")); XMLEvent event; while (xmler.hasNext()) { event = xmler.nextEvent(); if (event.isStartElement()) { System.out.println(event.asStartElement().getName()); } else if (event.isCharacters()) { System.out.println(event.asCharacters().getData()); } } } }