XMLStreamConstants.START_ELEMENT : XMLStreamConstants « javax.xml.stream « Java by API






XMLStreamConstants.START_ELEMENT

  



import java.io.File;
import java.io.FileInputStream;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;

public class Main {
  public static void main(String[] args) throws Exception {
    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    XMLStreamReader reader = inputFactory.createXMLStreamReader(new FileInputStream(new File("test.xml")));

    int eventTypeID = reader.nextTag();
    reader.require(XMLStreamConstants.START_ELEMENT, null, "person");

    eventTypeID = reader.nextTag();
    reader.require(XMLStreamConstants.START_ELEMENT, null, "first_name");
    System.out.println(reader.getElementText());

  }
}

   
    
  








Related examples in the same category

1.XMLStreamConstants.CDATA
2.XMLStreamConstants.CHARACTERS
3.XMLStreamConstants.END_ELEMENT
4.XMLStreamConstants.ENTITY_REFERENCE