1<?php 2dl('xmlwriter.so'); 3 4$xw = xmlwriter_open_memory(); 5xmlwriter_set_indent($xw, 1); 6$res = xmlwriter_set_indent_string($xw, ' '); 7 8xmlwriter_start_document($xw, '1.0', 'UTF-8'); 9// A first element 10xmlwriter_start_element_ns($xw,'prefix', 'books', 'uri'); 11xmlwriter_start_attribute($xw, 'isbn'); 12 13/* Uncomment this line if you have libxml 2.6.17 or CVS version 14 after 2005/02/22 15 earlier versions segfault 16*/ 17/* 18xmlwriter_start_attribute_ns($xw, 'prefix', 'isbn', 'uri'); 19xmlwriter_end_attribute($xw); 20*/ 21xmlwriter_end_attribute($xw); 22 23xmlwriter_text($xw, 'book1'); 24xmlwriter_end_element($xw); 25 26xmlwriter_end_document($xw); 27$out = xmlwriter_output_memory($xw, 0); 28 29echo $out; 30