1--TEST-- 2XMLWriter: libxml2 XML Writer, membuffer, flush, attribute 3--SKIPIF-- 4<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> 5--FILE-- 6<?php 7 8$doc_dest = '001.xml'; 9$xw = xmlwriter_open_memory($doc_dest); 10xmlwriter_start_document($xw, '1.0', 'UTF-8'); 11xmlwriter_start_element($xw, "tag1"); 12 13 14$res = xmlwriter_start_attribute($xw, 'attr1'); 15xmlwriter_text($xw, "attr1_value"); 16xmlwriter_end_attribute($xw); 17 18xmlwriter_write_attribute($xw, "att2", "att2_value"); 19xmlwriter_text($xw, "Test text for tag1"); 20$res = xmlwriter_start_element($xw, 'tag2'); 21if ($res < 1) { 22 echo "StartElement context validation failed\n"; 23 exit(); 24} 25xmlwriter_end_document($xw); 26 27// Force to write and empty the buffer 28echo xmlwriter_flush($xw, true); 29?> 30===DONE=== 31--EXPECT-- 32<?xml version="1.0" encoding="UTF-8"?> 33<tag1 attr1="attr1_value" att2="att2_value">Test text for tag1<tag2/></tag1> 34===DONE=== 35