XMLEvent: isCharacters() : XMLEvent « javax.xml.stream.events « Java by API






XMLEvent: isCharacters()

  



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());
      }
    }
  }
}

   
    
  








Related examples in the same category

1.XMLEvent.ATTRIBUTE
2.XMLEvent.COMMENT
3.XMLEvent.END_ELEMENT
4.XMLEvent.ENTITY_REFERENCE
5.XMLEvent.PROCESSING_INSTRUCTION
6.XMLEvent.SPACE
7.XMLEvent: asStartElement()
8.XMLEvent: isEndElement()