xref: /PHP-7.4/ext/xmlwriter/tests/003.phpt (revision d94a1907)
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$xw = xmlwriter_open_memory();
9xmlwriter_start_document($xw, '1.0', 'UTF-8');
10xmlwriter_start_element($xw, "tag1");
11
12
13$res = xmlwriter_start_attribute($xw, 'attr1');
14xmlwriter_text($xw, "attr1_value");
15xmlwriter_end_attribute($xw);
16
17xmlwriter_write_attribute($xw, "att2", "att2_value");
18xmlwriter_text($xw, "Test text for tag1");
19$res = xmlwriter_start_element($xw, 'tag2');
20if ($res < 1) {
21	echo "StartElement context validation failed\n";
22	exit();
23}
24xmlwriter_end_document($xw);
25
26// Force to write and empty the buffer
27echo xmlwriter_flush($xw, true);
28?>
29===DONE===
30--EXPECT--
31<?xml version="1.0" encoding="UTF-8"?>
32<tag1 attr1="attr1_value" att2="att2_value">Test text for tag1<tag2/></tag1>
33===DONE===
34