1--TEST-- 2XMLWriter: libxml2 XML Writer, comments 3--SKIPIF-- 4<?php 5if (!extension_loaded("xmlwriter")) die("skip"); 6if (!function_exists("xmlwriter_start_comment")) die("skip: libxml2 2.6.7+ required"); 7?> 8--FILE-- 9<?php 10 11$doc_dest = '001.xml'; 12$xw = xmlwriter_open_uri($doc_dest); 13xmlwriter_start_document($xw, '1.0', 'UTF-8'); 14xmlwriter_start_element($xw, "tag1"); 15 16xmlwriter_start_comment($xw); 17xmlwriter_text($xw, 'comment'); 18xmlwriter_end_comment($xw); 19xmlwriter_write_comment($xw, "comment #2"); 20xmlwriter_end_document($xw); 21 22// Force to write and empty the buffer 23$output_bytes = xmlwriter_flush($xw, true); 24echo file_get_contents($doc_dest); 25unset($xw); 26unlink('001.xml'); 27?> 28===DONE=== 29--EXPECT-- 30<?xml version="1.0" encoding="UTF-8"?> 31<tag1><!--comment--><!--comment #2--></tag1> 32===DONE=== 33