Get next tag from XMLStreamReader : XMLStreamReader « XML « Java






Get next tag from XMLStreamReader

  

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

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

public class MainClass {

  public static void main(String[] args) throws Exception {
    File file = new File("text.xml");

    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    XMLStreamReader reader = inputFactory.createXMLStreamReader(new FileInputStream(file));

    int eventTypeID = reader.nextTag();

    eventTypeID = reader.nextTag();

    eventTypeID = reader.next();
    System.out.println("Hello " + reader.getText());
  }
}

   
  








Related examples in the same category

1.Get event type from XMLStreamReader
2.Get next from XMLStreamReader
3.Event count
4.XML stream transform
5.Read Xml from StreamSource
6.Debugging utilities for XmlStreamReader