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