1--TEST-- 2XMLWriter: libxml2 XML Writer, membuffer, flush, text, attribute 3--SKIPIF-- 4<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> 5--FILE-- 6<?php 7/* $Id$ */ 8 9$xw = new XMLWriter(); 10$xw->openMemory(); 11$xw->startDocument('1.0', 'UTF-8'); 12$xw->startElement("tag1"); 13 14$res = $xw->startAttribute('attr1'); 15$xw->text("attr1_value"); 16$xw->endAttribute(); 17 18$res = $xw->startAttribute('attr2'); 19$xw->text("attr2_value"); 20$xw->endAttribute(); 21 22$xw->text("Test text for tag1"); 23$res = $xw->startElement('tag2'); 24if ($res < 1) { 25 echo "StartElement context validation failed\n"; 26 exit(); 27} 28$xw->endDocument(); 29 30// Force to write and empty the buffer 31echo $xw->flush(true); 32?> 33===DONE=== 34--EXPECT-- 35<?xml version="1.0" encoding="UTF-8"?> 36<tag1 attr1="attr1_value" attr2="attr2_value">Test text for tag1<tag2/></tag1> 37===DONE=== 38