Java: Utilisation de XMLStreamReader pour obtenir le tag suivant*

Author:

Java: Utilisation de XMLStreamReader  pour obtenir le tag suivant*
{filelink=8753}

/***** Code de MesExemples.com *******/
/**
 * @(#)NextTagXMLStreamReader.java
 *
 *
 * @author 
 *sakoba(java.mesexemples.com) @version 1.00 2013/7/5
 */
import java.io.File;
import java.io.FileInputStream;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;

public class NextTagXMLStreamReader {

  public static void main(String[] args) throws Exception {
    File file = new File("test2.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("Bienvenu " + reader.getText());
  }
    
    
}

Code testé avec le fichier XML Suivant




	Sakoba
	Adams
	Rappel
	Ne m'oubliez pas ce week-end!

Leave a Reply

Your email address will not be published. Required fields are marked *