Java XML: Utilisation du méthode writeStartDocument

Author:

Java XML: Utilisation du méthode writeStartDocument
Download

/***** Code de MesExemples.com *******/
  import javax.xml.stream.XMLOutputFactory;import javax.xml.stream.XMLStreamWriter;public class ExempleWriteStartDocument {  public static void main(String[] args) throws Exception {    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();    XMLStreamWriter writer = outputFactory.createXMLStreamWriter(System.out);    writer.writeStartDocument("1.0");    writer.writeStartElement("personne");    writer.writeStartElement("nom");    writer.writeStartElement("prenom");    writer.writeCharacters("X5");    writer.writeEndDocument();    writer.flush();  }}     

Code testé avec le fichier XML Suivant

<?xml version="1.0" encoding="windows-1252"?>
<!-- Edited by MesEXemple.com -->
<note>
	<to>Sakoba</to>
	<from>Adams</from>
	<heading>Rappel</heading>
	<body>Ne m'oubliez pas ce week-end!</body>
</note>

Cet article Java XML: Utilisation du méthode writeStartDocument est apparu en premier sur .