what is the purpose of getEventType() method in XMLStreamReader Class

Posted by KItis on Stack Overflow See other posts from Stack Overflow or by KItis
Published on 2010-05-22T18:55:37Z Indexed on 2010/05/22 19:00 UTC
Read the original article Hit count: 189

Filed under:
|

I have sample code written for parsing xml file using javax.xml package. it uses the method called getEventType() , but I can not understand the purpose of this method.

i wrote simple application to understand its usefulness, but it output only some random numbers for which I can not make any sense, could some one help me to get this point right.

Here is the sample code I have written.

public List parseXML(File f) throws XMLStreamException{
  xmlInputFactory = new WstxInputFactory();

  xmlInputFactory.setProperty(XMLInputFactory2.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
  xmlInputFactory.setProperty(XMLInputFactory2.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
  xmlInputFactory.setProperty(XMLInputFactory2.IS_COALESCING,Boolean.FALSE);
  xmlInputFactory.setProperty(XMLInputFactory2.IS_VALIDATING,Boolean.FALSE);
  xmlInputFactory.configureForSpeed();

  List<Task> tasks = new LinkedList<Task>();

  //xmlStreamReader = xmlInputFactory.createXMLStreamReader(new StringReader(dmml));
  xmlStreamReader = xmlInputFactory.createXMLStreamReader(f);

  int eventType = xmlStreamReader.getEventType();
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  eventType = xmlStreamReader.next();
  System.out.println(eventType);
  /*String currentElement = "";
  String currentElementText = "";
}

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml