Java XML: Ecrire un élément avec le namespace

Author:

Java XML: Ecrire un élément avec le namespace
{filelink=8758}

/***** Code de MesExemples.com *******/
  import javax.xml.stream.XMLOutputFactory;import javax.xml.stream.XMLStreamWriter;public class ExempleWriteNamespace
 {  public static void main(String[] args) throws Exception {    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();    XMLStreamWriter writer = outputFactory.createXMLStreamWriter(System.out);    writer.writeStartDocument("1.0");    writer.writeCharacters(" 
    ");    writer.writeStartElement("alpha", "exemple", "God");    writer.writeNamespace("Omega", "Johva");    writer.writeEmptyElement("http://www.mesexemples.com", "ns1");    writer.writeAttribute("UnAttribut", "true");    writer.writeEndElement();    writer.writeEndDocument();    writer.flush();    System.out.println();  }}     

Code testé avec le fichier XML Suivant




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

A Voir sur le même Sujet:

  • exemples programme java

Leave a Reply

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