
Read an XML Document with the StAX Iterator API
This tip shows an example of how to use the Iterator API to read from an XML file: import javax.xml.stream.*;import javax.xml.stream.events.*;import java.io.*;public class StAXBasicEventReader{ public StAXBasicEventReader(){} public static void main(String[] args) { XMLInputFactory XMLif=null; XMLEventReader XMLer=null; System.setProperty(“javax.xml.stream.XMLInputFactory”, “com.sun.xml.stream.ZephyrParserFactory”); //get an XMLInputFactory object XMLif=XMLInputFactory.newInstance(); //setting the XMLInputFactory corectly XMLif.setProperty(“javax.xml.stream.isSupportingExternalEntities”,Boolean.TRUE);XMLif.setProperty(“javax.xml.stream.isNamespaceAware”,Boolean.TRUE);XMLif.setProperty(“javax.xml.stream.isReplacingEntityReferences”,Boolean.TRUE); //getting an